CBSE COMPUTER SCIENCE
前往频道在 Telegram
QUESTION BANK, REFERENCE BOOK, LAB MANUAL , WORKSHEET ETC., PYTHON TEXT BOOK AND REFERENCE BOOKS, 01. ASK QUESTIONS AT https://t.me/joinchat/FJ1noGs-64I0OWI1
显示更多549
订阅者
无数据24 小时
无数据7 天
无数据30 天
帖子存档
#With Global
def check():
global num
num=1000
print(num)
num=100
print(num)
check()
print(num)
===================== RESTART: C:/Users/maha/globalscope.py ====================
100
1000
100
#Without global
def check():
num=1000
print(num)
num=100
print(num)
check()
print(num)
SQL Practice Questions – Test 13
Q121. Write the queries of the following on the basis of given table : Faculty
SQL Practice Questions
1. Display details of Faculties who joins after 1990.
Hide Answer
Ans. Select * from faculty where DOJ > “31-12-1990”;
2. Display details of Faculties whose salary is more than 20000.
Hide Answer
Ans. Select * from faculty where Fsal > 20000;
3. Show the name of faculties whose DOJ is 12-10-1980.
Hide Answer
Ans. Select Fname from faculty where DOJ = “12-10-1980”;
4. Display the detail of faculties whose name start from alphabet ‘A’.
Hide Answer
Ans. Select * from faculty where Fname like “A%”;
5. Display details of faculties whose salary is greater than 25000 and name ends with ‘n’.
Hide Answer
Ans. Select * from faculty where Fsal > 25000 and Fname like “%n”;
6. Count number of faculties whose name starts with ‘S’ and salary more than 40000.
Hide Answer
Ans. Select count(*) from faculty where Fname like “S%” and Fsal > 40000;
7. Display all records in increasing order of name.
Hide Answer
Ans. Select * from faculty order by Fname;
8. Display details of faculties who earns maximum.
Hide Answer
Ans. Select *, max(Fsal) from faculty;
OR
Select * from faculty where Fsal = (Select max(Fsal) from faculty);
9. Display name of lowest earning faculty.
Hide Answer
Ans. Select *, min(Fsal) from faculty;
OR
Select * from faculty where Fsal = (Select min(Fsal) from faculty);
10. Display “Annual Salary” of all faculties. (Given salary is monthly)
Hide Answer
Ans. Select Fsal * 12 as “Annual Salary” from faculty;
SQL Practice Questions – Test 12
Write the output of the following on the basis of given
Table : Product
SQL Practice Questions
Q111. Select max(price) from product;
Hide Answer
Ans. 320
Q112. Select avg(price) from product;
Hide Answer
Ans. 218
Q113. Select min(qty) from product;
Hide Answer
Ans. 17
Q114. Select count(*) from product;
Hide Answer
Ans. 5
Q115. Select count(Qty) from product;
Hide Answer
Ans. 5
Q116. Select distinct(price) from product;
Hide Answer
Ans.
240
300
320
130
100
Q117. Select count(distinct(price)) from product;
Hide Answer
Ans. 5
Q118. Select price * Qty from product;
Hide Answer
Ans.
5520
7200
13760
4160
1700
Q119. Select sum(price) from product;
Hide Answer
Ans. 1090
Q120. Select sum(price) where Qty > 30;
Hide Answer
Ans. Error
SQL Practice Questions – Test 11
Identify the errors in the following query
Q101 Select * from Student where Name = NULL;
Hide Answer
Ans. Select * from Student where Name is NULL;
Q102 Select max(salary) from employee group by designation where DOJ > “2020-02-02”;
Hide Answer
Ans. Select max(salary) from employee group by designation having DOJ > “2020-02-02”;
Q103 Select * from student where name is = “Amit”;
Hide Answer
Ans. Select * from student where name = “Amit”;
Q104 Select * from employee where salary between 1000, 2000;
Hide Answer
Ans. Select * from employee where salary between 1000 and 2000;
Q105. Select * from employee where name = “A%”;
Hide Answer
Ans. Select * from employee where name like “A%”;
Q106. Select Name , Subject from student where average >20 and < 30;
Hide Answer
Ans. Select Name , Subject from student where average >20 and average < 30;
Q107. Select * from Student where Name = “Amit” and Name =”Sumit”;
Hide Answer
Ans. Select * from Student where Name = “Amit” or Name = “Sumit”;
Q108. Select highest(Salary) from employee;
Hide Answer
Ans. Select max(Salary) from employee;
Q109. Select all from student;
Hide Answer
Ans. Select * from Student;
Q110. Update table student set Name = “Sunita” where admno = 1234;
Hide Answer
Ans. Update student set Name = “Sunita” where admno = 1234;
SQL Practice Questions – Test 10
Q91. What is the difference between drop and delete command?
Hide Answer
Ans. Drop command delete the data as well as structure of table permanently from database while delete command delete only the data from the table.
Q92. Differentiate between Alter and Update command.
Hide Answer
Ans. Alter command is used to change the structure of table and Update command is used to modify the data of table.
Q93. What is group by clause?
Hide Answer
Ans. This clause is used to arrange same data in groups using some group functions like Sum, average etc.
Write the output of the following:
Q94. Select 75 + 3*2
Hide Answer
Ans. 81
Q95. Select 23 + 56%5
Hide Answer
Ans. 24
Q96. Select power(2,3)
Hide Answer
Ans. 8
Q97 Select round(10.237,2)
Hide Answer
Ans. 10.24
Q98 Select round(12.3454,2)
Hide Answer
Ans. 12.35
Q99.Select round(12.3444,2)
Hide Answer
Ans. 12.34
Q100. Write the query on the basis of the following table : STUDENT
Name, Admno, Subject, Average, Position
a. Display all records in ascending order by name
Hide Answer
Ans. Select * from Student order by Name;
b. Display details of students whose position is “First” and average greater than 70
Hide Answer
Ans. Select * from student where position =”First” and Average >70;
SQL Practice Questions – Test 9
Q81. What do you mean by aggregate function?
Hide Answer
Ans. A function which work on multiple values and return a single value.
Q82. Which keyword is used to arrange records in increasing or decreasing order?
Hide Answer
Ans. Order by
Q83. Which function returns the total number of records in a table?
Hide Answer
Ans. Count( )
Q84. Select count( * ) from student; return 5 and Select count(fee) from student; return 4
why different output is coming in above two queries?
Hide Answer
Ans. Different output shows that there must be one null value in column fee.
Q85. ____________ function return the average value of a numeric column.
Hide Answer
Ans. avg( )
Q86. Which function returns the sum of numeric column?
Hide Answer
Ans. sum( )
Q87. _______ keywords removes duplicates records from the table.
Hide Answer
Ans. distinct
Q88. Write a query to display all the records of table student whose name starts from “A”
Hide Answer
Ans. Select * from student where name like “A%”;
Q89. Identify the error in the following statement.
Select * from student where name = null
Hide Answer
Ans. Select * from student where name is null;
Q90. Which function return the minimum value from column fee of table student?
Hide Answer
Ans. min( )
SQL Practice Questions – Test 8
Q71. Write the output of the following:
Select 76 + 75%4 from dual;
Hide Answer
Ans. 79
Q . Write the queries of the following:
Table : Student
SQL Practice Questions
Q72. Display all the records of table student.
Hide Answer
Ans. Select * from student;
Q73. Display Roll Number, Name and Class of table Student
Hide Answer
Ans. Select RollNo, Name , Class from student;
Q74. Display records of students of class X.
Hide Answer
Ans. Select * from student where class = ‘X’;
Q75. Display details of Sumit.
Hide Answer
Ans. Select * from student where Name = ‘Sumit’;
Q76. Display records of student paying fees less than 3000.
Hide Answer
Ans. Select * from students where fee < 3000;
Q77. Display fee of Amit
Hide Answer
Ans. Select fee from student where name = “Amit”;
Q78. Display Class and percentage of Pushkar.
Hide Answer
Ans. Select class, percentage from student where name = “Pushkar”
Q79. Delete record of Amit
Hide Answer
Ans. Delete from student where name = “Amit”
Q80. Display the structure of table student
Hide Answer
Ans. Desc student;
SQL Practice Questions – Test 7
Q61. Which command is used to delete data from the table?
Hide Answer
Ans. Delete
Q62. Which command is used to add column in a table?
Hide Answer
Ans. Alter
Q63. Write a query to add the column DOB of data type date in table Student.
Hide Answer
Ans. Alter table student add DOB date;
Q64. Write a query to add new column “Grade” of data type varchar(2) in table ‘Student’ with default value “A”.
Hide Answer
Ans. Alter table student add( Grade varchar(2) default “A”);
Q65. Write a query to change the data type of above added column (Grade) to varchar(4).
Hide Answer
Ans. Alter table student modify (Grade varchar(4));
Q66. Write a query to delete column Grade from table student.
Hide Answer
Ans. Alter table Student drop Grade;
Q67. ___________Command is used to delete table completely/permanently.
Hide Answer
Ans. Drop table
Q68. Write a query to delete the table “Emp” permanently.
Hide Answer
Ans. Drop table Emp;
Q69. Delete from emp;
The above command will delete all the records from table “emp”. (True/False)
Hide Answer
Ans. True
Q70. Write a query to display all the records from table “Student”
Hide Answer
Ans. Select * from Student;
SQL Practice Questions – Test 6
Q51. ___________ command is used to remove database completely.
Hide Answer
Ans. Drop
Q52. Which command is used to show the structure of the table.
Hide Answer
Ans. desc or describe.
Q53. Name the columns which are visible when we execute the following command.
desc book;
Hide Answer
Ans. Columns are:
Field, Type Null, Key, Default, Extra
Q54. Write the command to create the following table : “Student”
Field Name Data type Constraint
Rollno Integer (5) Primary Key
Sname Varchar(30)
Contactno Char(10) Not Null
Hide Answer
Ans. Create table student(Rollno integer(5) not null primary key, Sname varchar(30), Contactno char(10) not null);
Q55. Write query to insert the following record in above created table.
Roll number — 1, Name–Amit, Contact number– 1234567890
Hide Answer
Ans. Insert into student values(1, “Amit”, “123456780”);
Q56. Write a query to insert the following values only.
Roll number — 2 , Contact number– 11111111
Hide Answer
Ans. Insert into student(Rollno, Contactno) values(2 , ‘1111111’);
Q57. Is Null value is equivalent to Zero?
Hide Answer
Ans. No
Q58. What do you mean by Null in MySQL?
Hide Answer
Ans. Null means a value which is unavailable or in other words we can say Null means no value.
Q59. Which command is used to modify data in table?
Hide Answer
Ans. Update
Q60. Write a query to modify the Contactno to 98789878 whose roll number is 1 in table student.(given above)
Hide Answer
Ans. Update student set Contactno=’98789878′ where Rollno = 1;
SQL Practice Questions – Test 5
Q41. What do you mean by keyword in MySQL?
Hide Answer
Ans. Keyword refers to a word which has special meaning in MySQL.
Q42. Identify the keyword from the following query.
Select * from book;
Hide Answer
Ans. Keywords are : select and from
Q43. All statements in MySQL is terminated by __________.
Hide Answer
Ans. Semicolon(;)
Q44. We can create ____________ (database/tables)inside ___________(database/tables).
Hide Answer
Ans. tables, database
Q45. SQL is a case sensitive language(T/F)
Hide Answer
Ans. False
Q46. _________ statement is used to show all the existing databases in server.
Hide Answer
Ans. Show databases;
Q47. Which statement is used to show all existing table in database.
Hide Answer
Ans. Show tables;
Q48. Write statement to open a database named “student”.
Hide Answer
Ans. use student;
Q49. Name the command used to create database.
Hide Answer
Ans. Create database
Q50. Write statement to create database named “book”
Hide Answer
Ans. create database book;
SQL Practice Questions – Test 4
Q31. In MySQL, date values to be enclosed in { } or in single quotation marks(True/False)
Hide Answer
Ans. True
Q32. ______________ is the format of date in MySQL.
Hide Answer
Ans. yyyy/mm/dd
Q33. Data type of “name” field in a table is char(25). How many bytes will be occupied by values “Ram” and “Rohan Kumar”?
Hide Answer
Ans. 25
Q34. Time data type is used to store time in ________ format.
Hide Answer
Ans. hh:mm:ss
Q35. Varchar is a fixed length data type.(True/False)
Hide Answer
Ans. False
Q36. Name the command which is used to close MySQL.
Hide Answer
Ans. quit
Q37. Which data type in MySQL is used to store logical values?
Hide Answer
Ans. Boolean
Q38. Out of char, varchar and memo, which data type is used to store large amount of data?
Hide Answer
Ans. memo
Q39. Which data type in MySQL is used to store images, animations, clips etc.
Hide Answer
Ans. BLOB or RAW
Q40. Write the appropriate data types for the following fields.
DateofBirth
Salary
Name
Address
Phonenumber
Hide Answer
Ans.
Date
Any numeric data type preferable numeric or decimal.
Char or Varchar
Char or Varchar
Char or Numeric
SQL Practice Questions – Test 3
Q21. Write two advantages of SQL.
Hide Answer
Ans.
It is very easy to learn
It is not a case sensitive language.
Q22. MySQL is an ___________Software. (open source/Proprietary)
Hide Answer
Ans. open source
Q23. Name two types of SQL commands.
Show Answer
Q24. What is the difference between DDL and DML Commands?
Hide Answer
Ans.
DDL DML
It stands for Data Definition Language It stands for Data Definition Language
These commands allow to perform tasks
related to the structure of the table These commands are used to manipulate data
SQL Practice Questions
Q25. Identify the DDL and DML commands from the following.
Create
Alter
Insert
Update
Drop
Delete
Select
Hide Answer
Ans
DDL
DDL
DML
DML
DDL
DML
DML
Q26. What do you mean by data type?
Hide Answer
Ans. Data type refers to the type of data we are entering in the column of the table.
Q27. Name two numeric data type in MySQL.
Hide Answer
Ans. Integer and Smallint
Q28. Name two String Data type in MySQL.
Hide Answer
Ans. Char and Varchar
Q29. Which data type is used for “Date of birth” field in Student table.
Hide Answer
Ans. Date
Q30. What is the difference between Char and Varchar.
Hide Answer
Ans. Char is fixed length data type while Varchar is variable length data type.
