You are on page 1of 3

SQL INTERNAL QUERY TEST

1.What does SQL stand for?


Answer: Structured Query Language
2.Which SQL statement is used to extract data from a database?
Answer:
The Select statement is used to extract data from a database
3.Which SQL statement is used to update data in a database?
Answer:
The UPDATE statement is used to change the existing data in a database.

4.Which SQL statement is used to delete data from a database?


Answer:
The drop statement is used to delete data from a database
5. Which SQL statement is used to insert new data in a database?
Answer:
The INSERT INTO statement is used to insert new records in a table.

6.With SQL, how do you select a column named "FirstName" from a table named "Persons"?
Answer:
SELECT FirstName FROM Persons

7.With SQL, how do you select all the columns from a table named "Persons"?
Answer:
SELECT * FROM Persons

8.With SQL, how do you select all the records from a table named "Persons" where the value
of the column "FirstName" is "Peter"?
Answer:
SELECT * FROM Persons WHERE FirstName=’Peter’

9.With SQL, how do you select all the records from a table named "Persons" where the value
of the column "FirstName" starts with an "a"?
Answer:
SELECT * FROM Persons WHERE FirstName LIKE ‘a%’
10.The OR operator displays a record if ANY conditions listed are true. The AND operator
displays a record if ALL of the conditions listed are true. True or False?
Answer:
True
11.With SQL, how do you select all the records from a table named "Persons" where the
"FirstName" is "Peter" and the "LastName" is "Jackson"?
Answer:
SELECT * FROM Persons WHERE FirstName=’Peter’ AND LastName=’Jackson’
12.With SQL, how do you select all the records from a table named "Persons" where the
"LastName" is alphabetically between (and including) "Hansen" and "Pettersen"?
Answer:
SELECT * FROM Persons WHERE LastName BETWEEN ‘Hansen’ AND ‘Pettersen’
13.Which SQL statement is used to return only different values?
Answer:
SELECT DISTINCTstatement is used to return only different values

14.With SQL, how can you insert a new record into the "Persons" table?
Answer:
INSERT INTO Persons VALUES (‘vidya’, ‘megha’)
15.With SQL, how can you insert "Olsen" as the "LastName" in the "Persons" table?
Answer:
INSERT INTO Persons (LastName) VALUES (‘Olsen’)
16.How can you change "Hansen" into "Nilsen" in the "LastName" column in the Persons
table?
Answer:
UPDATE Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’
17.With SQL, how can you delete the records where the "FirstName" is "Peter" in the
Persons Table?
Answer:
DELETE FROM Persons WHERE FirstName = ‘Peter’
18.What is the most common type of join?
Answer:
The most common type of join is an INNER JOIN
19.Which operator is used to select values within a range?
Answer:
The BETWEEN operator is used in the where clause to select a value within a range of
values.
20.The NOT NULL constraint enforces a column to not accept NULL values. True or False?
Answer:
True
21.Which operator is used to search for a specified pattern in a column?
Answer:
The LIKE operator is used in a where clause to search for a specified pattern in a column.
22.Which SQL statement is used to create a database table called 'Customers'?
Answer:
The CREATE TABLE statement is used to create a new table in a database.
23.Which SQL statement is used to delete the table Market from database?
Answer:
Delete query
24.Which constraints are used to relate tables?
Answer:
foreign key constraints to define relationships between tables

25.Write a query to create table Shopping with two columns as ID and Name. Name column
must be created with allowing duplicates and ID column must be created with avoiding null
values?
Answer:
CREAT TABLE SHOPPING(ID int NOT NULL,Name varchar(50) )
insert into SHOPPING values(1,’vidya’);
insert into SHOPPING values(2,’megha’);
select *From SHOPPING;

You might also like