Font size
WorksheetsSQL Statements and Queries
Total questions: 15
Worksheet time: 23mins
What is the correct syntax of inserting to a database
INSERT INTO students (id, name, major) VALUES (1, 'Jane', 'Physics');
insert into students (id, name, major) values (1, 'Jane', 'Physics');
INSERT INTO students (id, name, major) VALUES (1, "Jane", "Physics");
INSERT INTO students (id, name, major) VALUES (1, 'Jane', 'Physics');
INSERT INTO students (id, name, major) VALUES (1, "Jane", "Physics");
What is the correct syntax when creating a primary key
CREATE TABLE Persons (
ID INT NOT NULL,
LName VARCHAR(255),
FName VARCHAR(255),
Age INT,
PRIMARY KEY (ID));
CREATE TABLE Persons (
ID INT NOT NULL PRIMARY KEY,
LName VARCHAR(255),
FName VARCHAR(255),
Age INT);
CREATE TABLE Persons (
ID PRIMARY KEY,
LName VARCHAR(255),
FName VARCHAR(255),
Age INT);
CREATE TABLE Persons (
ID PK,
LName VARCHAR(255),
FName VARCHAR(255),
Age INT);
BLOB is a datatype
True
False
Select all that are Constraints
delete
not null
primary key
varchar
all of the above
How do you delete a specific record in students table?
DELETE FROM students WHERE ID=1;
DELETE FROM student WHERE ID=1;
DELETE * FROM students;
DROP TABLE students;
Is it required to define a size for VARCHAR?
True
False
Choose the items that are SQL Functions
SUM()
AVG()
COUNT()
LIKE()
DELETE()
Fill in the correct condition if you want to list all students with the majors Bio and Chemistry:
SELECT * FROM students WHERE major = 'Bio' ____ major = 'Chemistry'
AND
OR
&&
||
What is the correct syntax when updating a name in the employees table?
UPDATE employees SET name = 'Bert';
UPDATE employee SET name = 'Bert';
ALTER table employees SET name = 'Bert';
ALTER table employee SET name = 'Bert';
Is it possible to insert empty values for a column that has NOT NULL constraint?
True
False
What is the default for order for ORDER BY?
ascending
descending
What is the syntax when removing a column from a table?
ALTER TABLE table_name REMOVE COLUMN column_name;
ALTER TABLE table_name DROP COLUMN column_name;
ALTER TABLE table_name DELETE COLUMN column_name;
all of the above
It is used to filter records from a single table
WHERE
UNION
INNER JOIN
OUTER JOIN
is used to combine results from two or more tables
INNER JOIN
OUTER JOIN
UNION
WHERE
What does this statement do:
SELECT name, age FROM employees ORDER BY 1;
sorts query result by name in ascending order
sorts query result by name in descending order
sorts query result by age in ascending order
sorts query result by age in descending order
