0% found this document useful (0 votes)
52 views

SQL

Uploaded by

almajerry
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

SQL

Uploaded by

almajerry
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1.A is a property of the entire relation, which ensures through its value that each tuple is unique in a relation.

(a) Rows (b) Key (c) Attributes (d) Fields


2.A relational database can have how many type of keys in a table ?
(a) Candidate Key (b) Primary Key (c) Foreign Key (d) All of these
3.Which one of the following uniquely identifies the tuples / rows in a relation.
(a) Secondary Key (b) Primary Key (c) Composite Key (d) Foreign Key
4.The Primary key is selected from the set Of.
(a) Composite Key (b) Determinants (c) Candidates Key (d) Foreign Key
5.Which of the following is a group of one or more attributes that uniquely identifies a row?
(a) Key (b) Determinant (c) Tuple (d) Relation
6.Which of the following attributes cannot be considered as a choice for Primary Key ?
(a) Id (b) License number (c) Dept_Id (d) Street
7.An attribute in a relation is a foreign key if it is the key in any other relation.
(a) Candidate (b) Primary (c) Super (d) Sub
8.Consider the table with structure as :Student(ID, name, dept_name, tot_cred)
In the above table, which attribute will form the primary key?
(a) name (b) dept_name (c) Total_credits (d) ID
9.Which of the following is not a legal sub-language of SQL ?
(a) DDL (b) QAL (c) DML (d) TCL
10.Which of the following is a DDL command?
(a) SELECT (b) ALTER (c) INSERT (d) UPDATE
11.In SQL, which of the following will select only one copy of each set of duplicate rows from a table.
(a) SELECT UNIQUE (b) SELECT DISTINCT (c) SELECT DIFFERENT (d)All of these.
12.Which of the following keywords will you use in the following query to display the unique values of the column
dept_name? SELECT dept_name FROM COMPANY;
(a) All (b) From (c) Distinct (d) Name
13.The clause of SELECT query allows us to select only those rows in the result that satisfy a specified condition.
(a) where (b) from (c) having (d) like
14.Which operator can take wild card characters for query condition?
(a) BETWEN (b) LIKE (c) IN (d) NOT
15.Which operator checks a value against a range of values?
(a) BETWEEN (b) LIKE (c) IN (d) NOT
16. Which of the following SQL commands retrives data from table(s) ?
(a) UPDATE (b) SELECT (c) Union (d) All of these
17. Which of the following queries contains an error ?
(a)Select * from emp where empid=10003; (b)Select empid from emp where empid=10006;
(c)Select empid from emp; (d)Select empid where empid=10009 and lastname= ‘GUPTA’;
18.Consider the following table namely Employee :
Employee_id Name Salary
1001 Misha 6000
1009 Khushi 4500
1018 Japneet 7000
Which of the names will not be displayed by the below given query ?
SELECT name from Employee WHERE employee_id>1009;
(a) Misha, Khushi (b) Khushi, Japneet (c) Japneet (d)Misha, Japneet
19.Which operator perform pattern matching ?
(a) BETWEN (b) LIKE (c) IN (d) NOT
20.Consider the following query
SELECT name FROM class WHERE Subject LIKE ‘ Informatics Practices’;
Which one of the following has to be added into the blank space to select the subject which has informatics practices
as its ending string?
(a) $ (b) _ (c) || (d) %
21.Which operator tests a column for the absence of data(i.e. NULL value) ?
(a) Exist Operator (b) NOT Operator (c) IS Operator (d) None of these

22.Which clause is used to sort the query result ?


(a) Order By (b) Sort By (c) Group By (d) Arrange By
23.By default ORDER BY clause list the result in order.
(a) Descending (b) Any (c) Same (d) Ascending
24. Consider the following query
SELECT * FROM employee ORDER BY salary, name;
To display the salary from greater to smaller and name in alphabetical order which of the following options should
be used ?
(a)Ascending, Descending (b)Asc, Desc (c)Desc, Asc (d)Descending, Ascending
25.What is the meaning of Remark LIKE “%5%5%”;
(a)Column Remark begin with two 5s (b)Column Remark ends with two 5s
(c)Column Remark has more than two 5s (d)Column Remark has two 5s in it, at any position
26.In SQL, which command(s) is/are used to change a table’s structure/characteristics?
(a) ALTER TABLE (b) MODIFY TABLE (c) CHANGE TABLE (d) All of these
27.Which of the following is/are the DDL Statement ?
(a) Create (b) Drop (c) Alter (d) All of these
28.A Table can have
(a)Many primary keys and many unique keys. (b)One primary key and one unique key
(c)One primary key and many unique keys. (d)Many primary keys and one unique key.
29. Which of the following types of table constraints will prevent the entry of duplicate rows?
(a) Unique (b) Distinct (c) Primary Key (d) Null
30.Consider the following SQL Statement. What type of statement is this ?
INSERT INTO instructor VALUES (10211, ‘SHREYA’ , ‘BIOLOGY’, 69000);
(a) Procedure (b) DML (c) DCL (d) DDL
31.Which of the following statements will delete all rows in a table namely mytable without deleting the table’s
structure.
(a)DELETE FROM mytable;’ (b)DELETE TABLE mytable; (c)DROP TABLE mytable; (d)None of these.
32.Which of the following query will drop a column from a table ?
(a)DELETE COLUMN column_name; (b)DROP COLUMN column_name;
(c)ALTER TABLE table_name DROP COLUMN column_name; (d)None of these
33.Logical operator used in SQL are:
(a) AND, OR, NOT (b) &&, ||, ! (c) $,|,! (d) None of these
34.Which of the following requirement can be implemented using a CHECK constraint?
(a)Student must be greater than 18 years old. (b)Student must be form a BRICS Country (Brazil, Russia, India, China,
South Africa) (c)Student’s roll number must exist in another table(say, namely Eligible) (d)None of these
35.An attribute in a relation is termed as a foreign key when it reference the of another relation.
(a) Foreign Key (b) Primary Key (c) Unique Key (d) Check Constraint
36.Data integrity constraints are used to :
(a)Control the access and rights for the table data. (b)Ensure the entry of unique records in a table.
(c)Ensure the correctness of the data entered in the table as per some rule or condition etc.
(d)Make data safe from accidental changes.
37.A relationship is formed via that relates two tables where one table references other table’s key.
(a) Candidate Key (b) Primary Key (c) Foreign Key (d) Check Constraint
38. What is the maximum value that can be stored in NUMBERIC(4,2)? (a) 9999.99 (b) 99.9999 (c) 99.99
(d) 9.99
39.What should be the data type for the column Price storing values less than Rs.1000 e.g. 200.21
(a) VARCHAR(50) (b) NUMBER (c) NUMBER(5,2) (d) NUMBER(6)
40.What is a name in the following SQL Statement ?
SELECT aname FROM table1 UNION SELECT aname FROM table2;
(a) row name (b) column Name (c) table name (d) database name
41.Data manipulation language (DML) includes statements that modify the of the tables of database.
(a) Structure (b) Data(c) User (d) Size
42.All aggregate functions ignore NULLs except for the function.
(a) Distinct (b) Count(*) (c) Average() (d) None of these
43.Which of the following are correct aggregate functions in SQL
(a) AVERAGE() (b) MAX() (c) COUNT() (d) TOTAL()
44.Identify the correct INSERT queries from the following :
(a)INSERT INTO Persons(‘xxx1’, ‘yyy1’); (b)INSERT INTO Persons(LastName, FirstName) Values (‘xxx’, ‘yyy’);
(c)INSERT INTO Persons Values(‘xxx1’ , ‘yyy1’); (d)INSERT INTO Persons Value(‘xxx1’ , ‘yyy1’);
FILL IN THE BLANKS
1. The SQL keyword is used to specify the table(s) that contains the data to be retrieved.
2. The command of SQL lets you make queries to fetch data from tables.
3. To remove duplicate rows from the result of a query, specify the SQL qualifier in select list.
4. To obtain all columns, use a(n) instead of listing all the column names in the select list.
5. The SQL clause contains the condition that specifies which rows are to be selected.
6. The SQL keyword is used in SQL expressions to select records based on patterns.
7. The operator is used for making range checks in SELECT queries.
8. The null values in a column can be searched for in a table using in the WHERE clause of
SELECT query.
9. To sort the rows of the result table, the clause is specified.
10. Columns can be sorted in descending sequence by using the SQL keyword .
11. By default, ORDER BY clause lists the records
in order.
12. A database can be opened with <database> command.
i. command is used to create new relations in a database
13. A is a condition or check applicable on a field or set of fields.
14. The constraint creates a foreign key.
15. To define a column as a primary key,
constraint is used in CREATE TABLE.
i. is used to insert data in an existing table.
16. Rows of a table can be deleted using command.
17. To increase the size of a
column in an existing table, use commond .
i. command removes a table from a database permanently.
ii. command is used to alter the definition of already created table.
18. To remove table data as well table structure, use command____________
19. Use___________ command to add new columns in an existing table.
20. A column added via ALTER TABLE command initially contains _____value for all rows.
21. Issue__________ command to make changes to table permanent.
22. The ________clause is used to divide result of SELECT query in groups.
23. To specify condition with a GROUP BY clause,_____clause is used.
24. Only_______ functions are used with GROUP BY clause.
25. Nested grouping can be done by providing___________ in the GROUP BY
expression.
26. The____________ clause is used in SELECT queries to specify filtering condition for groups.
27. Aggregate Functions cannot be used in____________ clause of the Select query.
28. The SQL built-in function______ total values in numeric columns.
29. The SQL built-in function_____ computes the average of values in numeric columns.
30. The SQL built-in function__ obtains the largest value in a in numeric columns.
31. The SQL built-in function___ obtains the smallest value in a in numeric columns.
32. The SQL built-in function____ computes the number of rows in a table.
33. The functions that work with one row at a time are________ functions.
34. To compare an aggregate value in a condition,_________ clause is used.
TRUE AND FALSE QUESTIONS
1. A primary key can store empty values in it.
2. Common attribute of two tables is called a foreign key.
3. A common attribute of two tables is called a foreign key it is the primary key in one table and the other table
reference it.
4. Part of SQL which creates and defines tables and other database objects, is called DDL
5. Part of SQL which manipulates data in tables, is called TCL
6. Part of SQL which access and manipulates data in tables is called DML
7. Part of SQL which controls transactions, is called TCL.
8. MySQL is name of customized query language used by Oracle.
9. SQL is a case sensitive.
10. The condition in a WHERE clause in a SELECT query can refer to only one value.
11. SQL provides the AS keyword, which can be used to assign meaningful column name to the results of queries
using the SQL built-in functions.
12. SQL is a programing language.
13. SELECT DISTINCT is used if a user wishes to see duplicate columns in a query.
14. ORDER BY can be combined with SELECT statement.
15. DELETE FROM <table> command is same as DROM TABLE <table> command.
16. The unique constraint can only be defined once in the CREATE TABLE command.
17. Unique and Primary Key constraints are the same.
18. Tuple based constraints can use multiple columns of the table.
OBJECTIVE TYPE QUESTIONS /MULTIPLE CHOICE QUESTIONS
1. The clause of SELECT query allows us to select only those rows in the results that
satisfy a specified condition.
(a) Where (b) from (c) having (d) like
2. Which of the following function is used to FIND the largest value from the given data in MYSQL?
(a) MAX () (b) MAXIMUM () (c) LARGEST () (c) BIG ()
3. The data types CHAR (n) and VARCHAR (n) are used to create and types of
string/text fields in a database.
(a) Fixed, equal (b) Equal, variable (c) Fixed, variable (d) Variable, equal
4. The term _ is use to refer to a record in a table.
(a) Attribute (b) Tuple (c) Row (d) Instance
5. A relational database consists of a collection of
(a) Tables (b) Fields (c) Records (d) Keys
6. Which is the subset of SQL commands used to manipulate database structure including tables?
(a) Data Definition Language (DDL) (b) Data Manipulation Language (DML)
(c) Both (a) and (b) (d) None
7. The term is used to refer to a field in a table.
(a) Attribute (b) Tuple (c) Row (d) Instance
8. Consider the following table namely employee:
Employee_id Name Salary
5001 Amit 60000

5009 Sumit 45000

5020 Arpit 70000

Which of the names will be displayed by the below given query? SELECT name FROM employee WHERE
employee_id>5009;
(a) Amit, Sumit (b) Sumit, Arpit (c) Arpit (d) Amit, Arpit
9. Consider the following query
SELECT name FROM stu WHERE subject LIKE ‘ Computer Science’;
Which one of the following has to be added into the blank spaces to select the subject which has Computer
Science as its ending string?
(a) $ (b) _ (c) || (d) %
10.Consider following SQL statement. What type of statement is this?
SELECT * FROM employee
(a) DML (b) DDL (c) DCL (d) Integrity constraint
11.Which of the following function is not an aggregate function?
(a) Round() (b) Sum() (c) Count () (d) Avg ()
12.Pick the correct username used for logging in database (sql with Python).
(a) root (b) local (c) directory (d) host
13.Aggregate functions can be used in the select list or the clause of a select statement. They
cannot be used in a clause.
(a) Where, having (b) Having, where (c) Group by, having (d) Group by, where
14.Select correct SQL query from below to find the temperature in increasing order of all cites.
(a) SELECT city FROM weather ORDER BY temperature;
(b) SELECT city, temperature FROM weather;
(c) SELECT city, temperature FROM weather ORDER BY temperature;
(d) SELECT city, temperature FROM weather ORDER BY city;
15.In SQL, which command is used to SELECT only one copy of each set of duplicable rows
(a) SELECT DISTINCT (b) SELECT UNIQUE
(c) SELECT DIFFERENT (d) All of the above
16.Which operator tests column for the absence of data (i.e., NULL value) ?
(a) EXISTS operator (b) NOT operator
(c) IS operator (d) None of these
17.Consider the following query:
SELECT name FROM class WHERE subject _NULL;
Which comparison operator may be used to fill the blank space in above query?
(a) = (b) LIKE (c) IS/IS Not (d) if

You might also like