Vidya SQL Internal Query Test
Vidya SQL Internal Query Test
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;