Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

SQL WS

The document contains a series of SQL-related questions covering topics such as aggregate functions, table properties, keys in RDBMS, SQL commands, and constraints. It also includes practical SQL command writing tasks and error identification in SQL queries. Additionally, it discusses the differences between various SQL clauses and data types.

Uploaded by

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

SQL WS

The document contains a series of SQL-related questions covering topics such as aggregate functions, table properties, keys in RDBMS, SQL commands, and constraints. It also includes practical SQL command writing tasks and error identification in SQL queries. Additionally, it discusses the differences between various SQL clauses and data types.

Uploaded by

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

1.

(i) Why is it not allowed to give string and date type argument for
Sum() and Avg() functions?
(ii) There is column C1 in a table T1.
The following two statements:
select count(*) from T1; and
select count(C1) from T1; are giving different output. What may be the possible
reason?
2 i) Which keyword is used to remove duplicate records from relation?
ii) A table "Design" in a database has 5 columns and 2 records. What is the
degree and cardinality of this table?
3. Differentiate between Primary Key and Foreign Key in RDBMS.
4. (i) Write the SQL Command to display all the rows from a table.
(ii) If there are ‘m’ rows in table-1 and ‘n’ rows in table-2, then how many
rows will be present in the Cartesian product of both the tables?
5.In MYSQL database, if a table, SCHOOL has degree 4 and cardinality 5, and
another table,STUDENT has degree 4 and cardinality 3,What will be the degree
and cardinality of the Cartesian product of SCHOOL and STUDENT?
a) 4,5 b)4,3 c)8,15 d)16,8
6.Which is not a constraint in SQL?
a) unique b)distinct c)Primary key d)Check
7.Choose the correct command to delete an attribute gender from a relation
student.
a)ALTER TABLE student DELETE gender
b)ALTER TABLE student DROP gender
c)ALTER TABLE DROP gender FROM student
d)DELETE gender FROM student8.Ms.Sita has just created a table named
“sweets” containing columns Sname, Quantity and Price.
After creating the table, she realized that she has forgotten to add a primary
key column in the table. Help her in writing an SQL command to add a primary
key column SID of integer type to the table sweets. Thereafter, write the
command to insert the following record in the table: SID- 999

Sname- Kaju Katli


Quantity : 40
Price : 2
9.a) In SQL, write the query to display the list of tables stored in a database.
(b) Sonal needs to display name of teachers, who have "O" as the third
character in their name. She wrote the following query.
SELECT NAME FROM TEACHER WHERE NAME="**O?"
But the query isn’t producing the result. Identify the problem.
10. (i) A table "Teachers" has three columns: TID, TNAME, and SUBJECT. Write a
SQL Command to add a new column in this table SALARY (of Integer type).
(ii) Categories the DDL and DML Commands from the following:
DROP, ALTER, SELECT, DELETE, INSERT, UPDATE
11. Which keyword is used to sort the records of a table in descending order?
12.(i) Which SQL logical operator is used to compare a value with a NULL value?
(ii) Which SQL logical operator is used to search for the presence of a row in a
specified table that meets a certain criterion?
13. Arvind is learning MySQL for managing different databases and tables for his
Python based application/software. Tell him the SQL commands for the
Following:-
(i) How to show pre-existing databases.
(ii) How to use a desired database
14 State True or False:
A primary key can store empty values in it:’15. Which among following
represent a logical relationship among a set of
values.
a. Attribute b. Key c. Tuple d. Field
16. Which of the following queries contains an error?
a. Select * From EMP where emp_id = 101
b. Select emp_id From EMP where emp_id = 102
c. Select emp_id From EMP
d. Select emp_id where emp_id = 109
17. Fill in the blank:
______ command is used to remove primary key from the table in SQL.
(a) update (b) remove (c) alter (d) drop
18. Differentiate between char(n) and varchar(n) data types with respect to
databases.
19.Write the full forms of DDL and DML commands. Write any 2 commands of
each in SQL.
20. _________is a non-key attribute, whose values are derived from the
primary key of some other table.
(A) Primary Key (B) Candidate Key (C) Foreign Key (D) Alternate Key
21. The SELECT statement when combined with clause, returns records without
repetition.
(A) DISTINCT (B) DESCRIBE (C) UNIQUE (D) NULL
22.Which of the following statements is True?
a) There can be only one Foreign Key in a table.
b) There can be only one Unique key in a table
c) There can be only one Primary Key in a Table
d) A table must have a Primary Key23.A SQL table EMPLOYEE contains the
following columns
ENO,ENAME,SALARY,DESIGNATION
Identify the command to remove the column designation from the table
EMPLOYEE
a)DELETE COLUMN DESIGNATION FROM EMPLOYEE
b) DROP COLUM DESIGNATION FROM EMPLOYEE
c)ALTER TABLE EMPLOYEE DROP COLUMN DESIGNATION’
d)UPDATE EMPLOYEE REMOVE DESIGNATION
24.Hari is working on a database table storing details of medicinal plants of
different types.He needs to display the number of plants of each type.As a team
leader,suggest asuitable function and clause to used by him from the following
options given.
a)sum(),group by b)count(),group by c)avg(),having d)count(),distinct
25.Select the appropriate clause to arrange the elements in a sorted form.
a)order b)sort by c)order by d)arrange by
26.Srishti needs to display the name of the teachers,who have ‘i’ as the last
character in their name.She wrote the following query.
SELECT NAME FROM TEACHER WHERE NAME=’’i’’;
But the query isn’t producing the result.Identify the problem and correct the
query.
27.What is alternate key?.Explain with an example.
28.What are constraints?Illustrate with an example.
29.Fill in the blank: ________ command is used to change table structure in
SQL.
(A) update (B) change (C) alter (D) modify30.Which of the following commands
will remove the entire database from
MYSQL?
(A) DELETE DATABASE (B) DROP DATABASE (C) REMOVE DATABASE (D) ALTER
DATABASE
31. _____ is a non-key attribute, whose values are derived from the primary key
of some other table.
(A) Primary Key (B) Candidate Key (C) Foreign Key (D) Alternate Key
32. The SELECT statement when combined with ________ clause, returns
records without repetition.
(A) DISTINCT (B) DESCRIBE (C) UNIQUE (D) NULL
33. Which function is used to display the total number of records from a table in
a database?
(A) total() (B) total(*) (C) return(*) (D) count(*)
34. Differentiate between order by and group by clause in SQL with appropriate
example.
35. Categorize the following commands as DDL or DML:
INSERT, UPDATE, ALTER, DROP
36. Which of the following is not part of a DDL query?
a) DROP b) MODIFY c) DISTINCT d) ADD
37. _______________ Keyword is used to obtain unique values in a SELECT
query
a) UNIQUE b) DISTINCT c) SET d) HAVING
38. Which statement in MySql will display all the tables in a database?
a) SELECT * FROM TABLES; b) USE TABLES; c) DESCRIBE TABLES; d) SHOW
TABLES39. Which of the following is a valid sql statement?
a) ALTER TABLE student SET rollno INT(5);
b) UPDATE TABLE student MODIFY age = age + 10;
c) DROP FROM TABLE student;
d) DELETE FROM student;
40. A MySQL table, sales have 10 rows.
The following queries were executed on the sales table.
SELECT COUNT(*) FROM sales;
COUNT(*)
10
SELECT COUNT(discount) FROM sales;
COUNT(discount)
10
Write a statement to explain as to why there is a difference in both the counts.

SECTION B

You might also like