1.3.2D SQL Flashcards
Write a SQL command to select all the columns from the “celebs” table.
SELECT * FROM celebs;
What type of programming language is SQL?
Declarative.
What type of programming language is SQL?
Declarative
Write a SQL command to select all the columns from the “celebs” table.
SELECT * FROM celebs;
Write a SQL command to insert the following data into the table “celebs”
Data:
1
Justin Bieber
21
Columns:
ID
Name
Age
INSERT INTO celebs ([ID], [Name], [Age]) VALUES (1, ‘Justin Bieber’, 21);
Write a SQL command to update the following data in the table “celebs”
Data:
1
Justin Bieber
21
Columns:
ID
Name
Age
Update age to 22.
UPDATE celebs
SET age = 22
WHERE id = 1;
Write a SQL command to update the following data in the table “celebs”
Data:
1
Justin Bieber
21
Columns:
ID
Name
Age
Update age to 22.
UPDATE celebs
SET age = 22
WHERE id = 1;
Write a SQL command to add a new column called “Twitter Handle” in the table named “celebs”, with the field type as text.
ALTER TABLE celebs ADD COLUMN [Twitter Handle] TEXT;
Write a SQL command to retrieve the columns “Name” and “IMDB Rating” in the table named “Movies”.
SELECT [Name], [IMDB_Rating] FROM [Movies];
Write a SQL command to retrieve the columns “Name” and IMDB Rating in the table named “Movies”.
SELECT [Name], [IMDB_Rating] FROM [Movies];
Write a SQL command to only retrieve unique values from the “Genre” column in the table named “Movies”.
SELECT DISTINCT [Genre] FROM [Movies];
Write a SQL command to retrieve movies where the “IMDB Rating” is greater than 8 in the table named “Movies”.
SELECT * FROM [Movies] WHERE [IMDB_Rating] > 8;
Write a SQL command to retrieve movie names (Name) where the movie name is like “Se*en”, where * represents any character, in the table named “Movies”.
SELECT * FROM [Movies] WHERE [Name] LIKE ‘Se_en’;
Write a SQL command to retrieve movie names (Name) where the movie name starts with “A”, in the table named “Movies”.
SELECT * FROM [Movies] WHERE [Name] LIKE ‘A%’;
Write a SQL command to retrieve movie names (Name) where the movie name ends with “a”, in the table named “Movies”.
SELECT * FROM [Movies] WHERE [Name] LIKE ‘%a’;