UPDATE, DELETE FROM, ALTER TABLE SQL Commands: SQL 30 Day Challenge Day 10

Опубликовано: 24 Июнь 2024
на канале: Learning with Jelly
177
13

Day 10 is about making changes to existing tables in a database. Many times we make mistakes, get new data processes, or need to make improvements; therefore, knowing how to update tables in SQL is vital. The UPDATE statement will allow you to update values in a table, the DELETE FROM statement will delete rows based on a condition, the ALTER table statement will let you modify the table on the back end.

Code to create the Pixar Films 2 Table (youtube doesn't like angled brackets so for
release_year make sure you put the greater than equal to sign where I say insert)!!!

--Change INSERT to greater than or equal to sign!!!!!!
Create table pixar_films2 (
film_id INTEGER PRIMARY KEY AUTOINCREMENT,
film_title TEXT NOT NULL,
release_year INTEGER NOT NULL CHECK(release_year INSERT 1995),
director TEXT,
tomatoes_score INTEGER CHECK(tomatoes_score BETWEEN 0 AND 100)
);

INSERT INTO pixar_films2 (film_title, release_year, director, tomatoes_score)
VALUES ('Toy Story', 1995, 'John Lasseter', 100),
('Finding Nemo', 2003, 'Andrew Stanton', 99),
('Inside Out', 2015, 'Pete Docter', 98);

select * from pixar_films2;

Questions:

/* 1. Update pixar_films2 with title "A Bug's Life"
and a tomatoes score of 92 where film id is 1*/

/*2. Delete the row that has the title
Inside Out from the table */

/*3. Alter table to add
runtime to the table */

/*Homework:
1. Use alter table statement to rename
column release_year to year*/

/*2. Update the tomatoes score of Finding Nemo
to be 100*/
-----------------------------------------------------------------
Download SQLite Studio Here: https://sqlitestudio.pl/
Download the Chinook Database: https://www.sqlitetutorial.net/sqlite...

Link to Topic List: https://docs.google.com/document/d/1f...
Link to Facebook Support Group:   / 767988395118964  

Link to my Data Etsy Shop (support me to keep making content): https://jellysgeekygoods.etsy.com
Buy me a coffee to show support: https://buymeacoffee.com/learningwith...

#sql #sqltutorial #sqlforbeginners