Font size
WorksheetsDDL ප්රශ්න
Total questions: 52
Worksheet time: 49mins
What is the command used to completely remove the column student_age from the students table?
REMOVE COLUMN student_age FROM students;
DROP COLUMN student_age FROM students;
ALTER TABLE students DROP COLUMN student_age;
DELETE COLUMN student_age FROM students;
TRUNCATE TABLE students COLUMN student_age;
What is the command to create a new table named teachers that includes the columns teacher_id (INTEGER PRIMARY KEY), teacher_name (VARCHAR(100)), and subject (VARCHAR(50))?
CREATE TABLE teachers (teacher_id INT PRIMARY KEY, teacher_name VARCHAR(100), subject VARCHAR(50));
MAKE TABLE teachers (id INT, name VARCHAR, subject VARCHAR);
CREATE TABLE teachers (teacher_id INTEGER, teacher_name VARCHAR, subject VARCHAR);
NEW TABLE teachers (id INT PRIMARY KEY, name VARCHAR(100));
ALTER TABLE teachers ADD (id INT, name VARCHAR, subject VARCHAR);
What is the most efficient command to delete all data from the students table while keeping its structure?
DELETE FROM students;
DROP TABLE students;
TRUNCATE TABLE students;
REMOVE ALL FROM students;
CLEAR TABLE students;
What command is used to completely remove the students table along with all its data and structure?
DELETE FROM students;
REMOVE students;
TRUNCATE TABLE students;
DROP TABLE students;
ERASE TABLE students;
What is the correct command to add a new column named student_gpa to the students table?
What is the correct command to add a new column named student_gpa to the students table?
ADD COLUMN student_gpa TO students;
ALTER TABLE students ADD student_gpa DECIMAL(3,2);
CREATE COLUMN student_gpa IN students;
INSERT COLUMN student_gpa IN students;
UPDATE TABLE students ADD student_gpa;
What is the correct command to rename the column course_name to subject_name in the courses table?
RENAME COLUMN course_name TO subject_name IN courses;
ALTER TABLE courses RENAME COLUMN course_name TO subject_name;
UPDATE TABLE courses SET course_name = subject_name;
CHANGE COLUMN course_name TO subject_name FROM courses;
MODIFY COLUMN course_name TO subject_name IN courses;
What is the correct command to add a new column named student_phone to the students table and add a UNIQUE constraint to it?
What is the correct command to add a new column student_phone to the students table with a UNIQUE constraint?
ALTER TABLE students ADD student_phone VARCHAR(15) UNIQUE;
CREATE UNIQUE COLUMN student_phone IN students;
ALTER TABLE students MODIFY student_phone VARCHAR(15) UNIQUE;
UPDATE TABLE students ADD student_phone UNIQUE;
ADD COLUMN student_phone VARCHAR(15) UNIQUE TO students;
What does NOT NULL mean when using the CREATE TABLE command?
It is a constraint that ensures a column's value cannot be NULL.
It is a constraint that ensures a column's value must be NULL.
It is a constraint that automatically increments a column's value.
It is a constraint that ensures data must be included in a table.
It is a constraint that prohibits data from being included in a table.
What is the correct DDL command to change the student_id column from INT to BIGINT in the students table?
What is the correct DDL command to change the student_id column from INT to BIGINT in the students table?
ALTER TABLE students ALTER COLUMN student_id BIGINT;
MODIFY TABLE students SET student_id BIGINT;
UPDATE students SET student_id = BIGINT;
CHANGE COLUMN student_id TO BIGINT IN students;
RENAME student_id TO BIGINT FROM students;
What is the correct SQL command to retrieve the names and ages of all students from the students table?
SELECT student_name, student_age FROM students;
GET student_name, student_age FROM students;
RETRIEVE name, age FROM students;
FIND student_name, student_age FROM students;
SELECT * FROM students;
What is the correct SQL command to retrieve the data of all students whose student_city value is 'Colombo'?
What is the correct SQL statement to retrieve data for all students where the value in the student_city column of the students table is 'Colombo'?
SELECT * FROM students WHERE student_city = 'Colombo';
SELECT * FROM students IF student_city = 'Colombo';
SELECT student_city = 'Colombo' FROM students;
FIND students WHERE city = 'Colombo';
SELECT * FROM students HAVING student_city = 'Colombo';
What is the command to insert a new row into the enrollments table with enrollment_id = 'E6', student_id = 101, course_id = 'C101', enrollment_date = '2024-04-01'?
ADD INTO enrollments VALUES ('E6', 101, 'C101', '2024-04-01');
INSERT INTO enrollments VALUES ('E6', 101, 'C101', '2024-04-01');
CREATE enrollment ('E6', 101, 'C101', '2024-04-01');
UPDATE enrollments SET enrollment_id = 'E6';
PUT INTO enrollments VALUES ('E6', 101, 'C101', '2024-04-01');
What is the student_id in the students table?
What command is used to change the student_city of student_id 104 to 'Ratnapura' in the students table?
INSERT INTO students SET student_city = 'Ratnapura' WHERE student_id = 104;
ALTER TABLE students UPDATE student_city = 'Ratnapura' WHERE student_id = 104;
UPDATE students SET student_city = 'Ratnapura' WHERE student_id = 104;
MODIFY students SET student_city = 'Ratnapura' WHERE student_id = 104;
CHANGE students SET student_city = 'Ratnapura' WHERE student_id = 104;
What command is used to delete all students under the age of 21 from the students table?
TRUNCATE TABLE students WHERE student_age < 21;
DROP FROM students WHERE student_age < 21;
DELETE FROM students WHERE student_age < 21;
REMOVE FROM students WHERE student_age < 21;
ALTER TABLE students DELETE WHERE student_age < 21;
What is the correct command to delete rows from the students table where student_age is less than 21?
DELETE FROM students WHERE student_age < 21;
REMOVE FROM students WHERE student_age < 21;
ALTER TABLE students DELETE WHERE student_age < 21;
What command is used to sort the names of students in the students table alphabetically?
SELECT * FROM students ORDER BY student_name ASC;
SELECT * FROM students SORT BY student_name;
SELECT * FROM students GROUP BY student_name;
SELECT * FROM students WHERE student_name ORDER BY ASC;
ORDER BY student_name FROM students;
What is the correct command to retrieve data from students in the cities 'Colombo' and 'Galle'?
SELECT * FROM students WHERE student_city = 'Colombo' OR student_city = 'Galle';
SELECT * FROM students WHERE student_city IN ('Colombo', 'Galle');
SELECT * FROM students WHERE student_city LIKE 'Colombo' AND 'Galle';
a and b
What is the command to retrieve data from the students table where student_city is either 'Colombo' or 'Galle'?
SELECT * FROM students WHERE student_city = 'Colombo' OR student_city = 'Galle';
SELECT * FROM students WHERE student_city IN ('Colombo', 'Galle');
SELECT * FROM students WHERE student_city LIKE 'Colombo' AND 'Galle';
Both a and b are correct.
None of the above.
What command is used to count the number of rows in the students table?
SELECT COUNT(*) FROM students;
SELECT COUNT(students);
SELECT NUMBERS FROM students;
SELECT COUNT(rows) FROM students;
SELECT SUM(*) FROM students;
What command is used to get the average value of course_credits in the courses table?
SELECT AVG(course_credits) FROM courses;
SELECT SUM(course_credits) FROM courses;
SELECT COUNT(course_credits) FROM courses;
SELECT AVERAGE(course_credits) FROM courses;
SELECT course_credits FROM courses GROUP BY AVG;
What is the command used to get the average of numeric values in a column?
SELECT AVG(course_credits) FROM courses;
SELECT course_credits FROM courses GROUP BY AVG;
What command is used to get the count of students from the city 'Colombo' in the students table?
SELECT COUNT(student_city) FROM students;
SELECT COUNT(student_city = 'Colombo') FROM students;
SELECT COUNT(*) FROM students WHERE student_city = 'Colombo';
SELECT SUM(student_city) FROM students WHERE student_city = 'Colombo';
SELECT student_city, COUNT(*) FROM students;
What is the correct command to get all students whose names start with the letter 'N' from the student_name column in the students table?
SELECT * FROM students WHERE student_name = 'න%';
SELECT * FROM students WHERE student_name LIKE 'න%';
SELECT * FROM students WHERE student_name BEGINS 'න';
SELECT * FROM students WHERE student_name STARTING WITH 'න';
SELECT * FROM students WHERE student_name = 'න*';
What is the correct command to retrieve data for students aged between 20 and 22 (inclusive) from the students table?
SELECT * FROM students WHERE student_age >= 20 AND student_age <= 22;
SELECT * FROM students WHERE student_age BETWEEN 20 AND 22;
SELECT * FROM students WHERE student_age > 19 AND student_age < 23;
Both a and b are correct.
None of the above.
What is the correct command to delete data for students with student_id 101 and 103 from the students table?
DELETE FROM students WHERE student_id = 101 AND 103;
DELETE FROM students WHERE student_id IN (101, 103);
REMOVE FROM students WHERE student_id = 101 OR student_id = 103;
Both b and c are correct.
TRUNCATE FROM students WHERE student_id IN (101, 103);
What is the correct command to retrieve data from the students table where the student_name column contains the letter 'ම'?
SELECT * FROM students WHERE student_name CONTAINS 'ම';
SELECT * FROM students WHERE student_name LIKE '%ම%';
SELECT * FROM students WHERE student_name = '%ම%';
SELECT * FROM students WHERE student_name HAVING 'ම';
SELECT * FROM students WHERE student_name IN 'ම';
What is the command used to get the maximum value of student_age in the students table?
SELECT MAX(student_age) FROM students;
SELECT TOP(student_age) FROM students;
SELECT LARGEST(student_age) FROM students;
SELECT COUNT(student_age) FROM students;
SELECT AVG(student_age) FROM students;
What is the output of the command SELECT * FROM students?
Only the column names in the students table.
The number of data rows in the students table.
All the data in the students table.
The data in the first row of the students table.
The average of the data in the students table.
What command is used to display data of students older than 21 in descending order by age?
SELECT * FROM students WHERE student_age > 21 ORDER BY student_age DESC;
SELECT * FROM students ORDER BY student_age DESC WHERE student_age > 21;
SELECT * FROM students WHERE student_age > 21 SORT BY student_age;
SELECT * FROM students WHERE student_age > 21 AND ORDER BY student_age DESC;
ORDER BY student_age DESC FROM students WHERE student_age > 21;
What is the correct command to change the name of the student with student_id 101 to 'Sanath' and age to 25?
UPDATE students SET student_name = 'සනත්' AND student_age = 25 WHERE student_id = 101;
ALTER TABLE students SET student_name = 'සනත්', student_age = 25 WHERE student_id = 101;
UPDATE students SET student_name = 'සනත්', student_age = 25 WHERE student_id = 101;
MODIFY students SET student_name = 'සනත්', student_age = 25 WHERE student_id = 101;
CHANGE students SET student_name = 'සනත්', student_age = 25 WHERE student_id = 101;
What is the command to insert a new data row under enrollment_id E6 into the enrollments table with student_id 102 and course_id C101?
What is the command to insert a new data row under the enrollment_id 6, including student_id 102 and course_id C101?
INSERT INTO enrollments (enrollment_id, student_id, course_id) VALUES ('E6', 102, 'C101');
INSERT INTO enrollments VALUES ('E6', 102, 'C101');
ADD TO enrollments ('E6', 102, 'C101');
UPDATE enrollments SET enrollment_id = 'E6', student_id = 102, course_id = 'C101';
CREATE enrollment ('E6', 102, 'C101');
What is the command used to delete all data of the student with student_id 102 from the students table?
DROP FROM students WHERE student_id = 102;
TRUNCATE TABLE students WHERE student_id = 102;
DELETE FROM students WHERE student_id = 102;
REMOVE FROM students WHERE student_id = 102;
ALTER TABLE students DROP student_id = 102;
Which of the following options contains only a DDL command?
SELECT
UPDATE
CREATE
INSERT
DELETE
Which of the following statements is only a DDL statement?
SELECT
UPDATE
CREATE
INSERT
DELETE
ALTER TABLE belongs to which category of SQL statements?
DML
DCL
DDL
TCL
DQL
What is the main difference between DELETE FROM students; and TRUNCATE TABLE students;?
DELETE is DDL while TRUNCATE is DML.
DELETE can use a WHERE clause while TRUNCATE cannot.
TRUNCATE also removes the structure of the students table.
DELETE is slower than TRUNCATE when removing data.
DELETE is DML while TRUNCATE is DDL.
Which of the following statements is not a DML statement?
Which of the following statements is not a DML statement?
SELECT
INSERT
UPDATE
ALTER
DELETE
To which SQL categories do the statements CREATE TABLE and INSERT INTO belong?
Both are DML
Both are DDL
CREATE TABLE is DML, INSERT INTO is DDL
CREATE TABLE is DDL, INSERT INTO is DML
Both are DCL
What is the common characteristic between DROP TABLE and TRUNCATE TABLE?
Both are DML statements.
Both only delete data from a table.
Both are DDL statements.
Both only change the structure of a table.
Both use a WHERE clause.
What is the difference between the statements UPDATE and ALTER?
What is the difference between the UPDATE and ALTER commands?
UPDATE changes the structure of a table, while ALTER changes the data.
Both UPDATE and ALTER are used for the same task.
UPDATE is DML and changes the data in the table. ALTER is DDL and changes the structure of the table.
UPDATE is DDL and ALTER is DML.
UPDATE adds columns, while ALTER inserts data.
When using the SELECT command to retrieve data, does it change the data in the database?
Yes, it changes the data.
No, it does not change the data; it only retrieves data.
It changes the data only if a WHERE clause is used.
It changes the data only if a JOIN clause is used.
It changes the data only if an ORDER BY clause is used.
Methods that can be used with the INSERT INTO command without a VALUES clause
What is the method that can be used when using the INSERT INTO statement without a VALUES clause?
Inserting data from another table using a SELECT statement.
Using an UPDATE statement.
Using a DELETE statement.
Using an ALTER statement.
Using a DROP statement.
What is the correct option that contains a statement that belongs to both DML and DDL?
INSERT and CREATE
SELECT and ALTER
UPDATE and DROP
All of the above
All options a, b, c contain both DML and DDL statements.
