Answers of textbook exercises
Fill in the Blanks
1. DML stands for D a t a M a n i p u l a t i o n L a n g u a g e.
2. You can add a new row to a table using the i n s e r t command.
3. The operator used for multiple character wildcards is %.
4. The SQL keyword l i k e is used with wildcards.
5. SQL commands that modify database data are called D M L.
State True or False
1. WHERE clause cannot be used with DELETE statement.-False
2. SQL uses FROM clause to name the source table in a select query.-True
3. DISTINCT keyword eliminates duplicate records.-True
4. In SQL % (Percentage) is used as a single character wildcard.-False
5. CREATE is a DML statement.-False
Match the Following
1. Insert Values
2. Wildcard
Pattern matching
3. Update
Set
4. Read
Select
5. \
Escape character
Multiple choice questions
1. What is the use of WHERE clause in SQL?
1. Filter the columns that are returned.
2. Filter the rows that are returned.
3. Select the last column.
4. Select all rows.
2. Which of the following SQL Statement(s) is correct?
1. SELECT username AND password FROM tb1_login.
2. SELECT username, password WHERE user
username="Cybersquare"
3. SELECT username, password FROM tb1_login.
4. All of the above.
3. The wildcard in a WHERE clause is used when?
1. Exact match is necessary in a SELECT statement.
2. Exact match is not possible in a SELECT statement.
3. Exact match is necessary in a CREATE statement.
4. Exact match is not possible in a CREATE statement.
4. Which of the following is the correct order of keywords for SQL SELECT
statements?
1. FROM, WHERE, SELECT
2. SELECT, FROM, WHERE
3. WHERE, FROM, SELECT
4. SELECT, WHERE, FROM
5. Which of the following is not a DML?
1. Insert
2. Update
3. Delete
4. Truncate
Answer in one word or one sentence
1. How can you remove a record with the name “John” from the person's
table?
DELETE FROM persons WHERE name=’John’;
2. Write down the syntax of the insert statement.
INSERT INTO table_name (column1,column2,column3,...)
VALUES (value1,value2,value3,...);
3. What is the full form of CRUD?
C - Create
R - Read
U - Update
D - Delete
4. What will happen if you do not use the WHERE condition with delete
statement?
The whole table data will be deleted.
5. What is the use of the ORDER BY keyword?
ORDER BY keyword is used to sort the result-set in
ascending or descending order.
Answer the following
1. What is a CRUD operation?
Once we have created the table structures using the data
definition language, we are ready to insert (store) data into
the database. Once we insert it we can retrieve (select)
update and delete data. These are usually called CRUD
operations.
2. Write down the syntax of any three DML statements.
INSERT INTO table_name(column1,column2,column3,..)
VALUES(value1,value2,value3,...);
SELECT what_to_select FROM table_name WHERE
conditions_to_satisfy;
UPDATE table_nameSET column1=value1, column2=value2,...
WHERE condition;
DELETE FROM table_name WHERE some_column = some_value.
3. Write down the query to create the following table.
Column name Data type Constraint
Id int Primary key
Username Varchar Unique
Password Varchar
Name Varchar
Date of birth Date
Genter Character
CREATE TABLE User (Id int, Username varchar(30) UNIQUE,
Password varchar(20),Name varchar(20),Date_of_birth date,
Gender char,PRIMARY KEY (Id);
4. Explain DML statements.
DML is used for managing data within schema objects. The
following are the main DML operations.
INSERT
SELECT
UPDATE
DELETE
5. What are the different clauses in SQL?
WHERE
HAVING
GROUP BY
ORDER BY