在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):ga-wdi-exercises/library_sql开源软件地址(OpenSource Url):https://github.com/ga-wdi-exercises/library_sql开源编程语言(OpenSource Language):TSQL 100.0%开源软件介绍(OpenSource Introduction):Library DBGet StartedClone down this repo and open its contents in VSCode. Then read through and follow the steps below. Creating Our DatabaseOne of two ways! From within your terminal environment: $ createdb library Or # launch the psql cli
$ psql
# create the db using a SQL command
> CREATE DATABASE library; Inspecting The SchemaLook critically at each line of the provided
Take a few minutes to research the other rows. Load The SchemaLoad the schema into your database from the command line... $ psql -d library < schema.sql
Loading A Seed FileWe've provided a sql file that adds sample data into our Load that in so we can practice interacting with our data. Make sure to also look at its contents and see how authors and books are related. $ psql -d library < seed.sql Performing CRUD actions with SQLCRUD stands for the most basic interactions we want to have with any database: Create, Read, Update and Destroy. The most common SQL commands correspond to these 4 actions...
First, enter into the library DB... $ psql
$ \c library INSERT
INSERT INTO authors(name, nationality, birth_year) VALUES ('Adam Bray', 'United States of America', 1985); SELECT
-- select all columns from all rows
SELECT * FROM authors;
-- select only some columns, from all rows
SELECT name, birth_year FROM authors;
-- select rows that meet certain criteria
SELECT * FROM authors WHERE name = 'James Baldwin'; UPDATE
UPDATE authors SET name = 'Adam B.', birth_year = 1986 WHERE name = 'Adam Bray'; DELETE
DELETE FROM authors WHERE name = 'Adam B.';
ExercisesThere are two exercises:
For each exercise, write your queries in the corresponding .sql file. Then run the file using the terminal: $ psql -d library < basic_queries.sql |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论