Font size
WorksheetsMySql commands
Total questions: 136
Worksheet time: 1hrs 9mins
What does SQL stand for?
Structured Query Language
Structured Question Language
Strong Question Language
None of the above
Which of the following can add a row to a table?
Add
Insert
Update
Alter
What does DML stand for?
Data Manipulation Language
Data Modeling Language
Data Markup Language
Data Migration Language
Which of the following is not a keyword of MYSQL?
Select
Top
Group
Insert
Which of the following query is correct to get Current Date from Query?
A. SELECT DATE ( NOW() ) as today;
B. SELECT DATE_FORMAT( NOW( ) , '%Y-%m-%d' ) as today;
A. SELECT DATE ( NOW() ) as today;
B. SELECT DATE_FORMAT( NOW( ) , '%Y-%m-%d' ) as today;
Both A and B
None
Which of the following is not a valid aggregate function?
COUNT
MIN
COMPUTE
MAX
The _________ statement is used to delete a table.
DROP TABLE
DELETE TABLE
DEL TABLE
REMOVE TABLE
Which one of the following sorts rows in SQL?
SORT BY
ALIGN BY
GROUP BY
ORDER BY
The SQL statement that queries or reads data from a table is __________ .
USE
SELECT
READ
QUERY
Which SQL statement is used to return only different values?
SELECT DISTINCT
SELECT UNIQUE
SELECT DIFF
SELECT DIFFERENT
With SQL, how do you select all the columns from a table named "Persons"?
SELECT * FROM Persons
SELECT Persons
SELECT [all] FROM Persons
SELECT *.Persons
In a LIKE clause, you can ask for any 6 letter value by writing
LIKE ______ (that's six underscore characters)
LIKE ...... (that's six dots)
LIKE .{6}
LIKE ??????
Which SQL statement is used to update data in a database?
MODIFY
ALTER
SAVE
UPDATE
SQL can be used to:
Create database structures only.
Query database data only.
Modify database data only.
All of the above can be done by SQL.
The SQL keyword BETWEEN is used:
For ranges.
To limit the columns displayed.
As a wildcard.
None of the above
Which clause is used to “Filters out unwanted data”?
FROM
SELECT
ORDER BY
WHERE
Write a query to display first_name and last_name of all employees who have their first_name starting with 'A'.
Select first_name from employess where first_name LIKE '%A';
Select first_name from employess where first_name LIKE "'A'%";
Select first_name from employess where first_name LIKE 'A%';
Select first_name from employess where first_name LIKE '%A%';
A relational database can have how many types of keys in a table ?
Candidate key
Primary key
Foreign key
All of these
Which one of the following uniquely identifies the tuples/tows in a relation ?
Secondary key
Primary key
Composite key
Foreign key
SELECT is a DDL/DML command ....
DDL
DML
None of these
Both
Which of the following keywords will you use to display unique values of the column dept_name ?
SELECT ______ dept_name from COMPANY;
All
distinct
from
name
Which of the following SQL commands retrieves data from table(s)?
update
select
insert
delete
INSERT INTO EMP VALUES(101,'SUMAN','MANAGER');
Which kind of statement is this ?
DDL
DML
Value
Python statement
What will be the output for :-
SELECT LENGTH("EMPLOYEE");
10
8
EMPLOYEE
1
What will be the output for :-
SELECT ROUND(153.669,2);
153.6
153.7
153.67
153.66
Total number of rows/records/horizontal arrangement in a table is called:
Degree
Records
Integer
Cardinality
Which SQL statement is used to delete an existing row ?
DROP
REMOVE
DELETE
UPDATE
What will be the output for SELECT LENGTH("HELLO")
5
7
HELLO
ERROR
The total number of rows in a table is called as
integer
degree
cardinality
tuples
INSERT INTO EMP VALUES(1221, 'ABC', 'MANAGER',12323); What kind of statement is this ?
DDL
DML
DCL
TCL
Which SQL command is used to remove rows from the table customer?
Drop from customer ;
Update from customer;
remove from customer ;
Delete from customer where condition ;
Which SQL keyword is used to sort the result-set?
Sort by
order by
sort
none of these
Which of the following must be enclosed in double quotes?
Date
Column alias
String
All of the above
An organized collection of data stored in a central location is known as?
database
flat file
csv
none of these
Which type of database management system represents relations using tables?
Network DBMS
Relational DBMS
Object Oriented DBMS
Hierarchical DBMS
Which of the following scripts will run successfully?
SELECT customer name FROM customers;
SELECT FROM `customers` 'customer name';
SELECT `customer name` FROM customers ORDER BY zone WHERE cat_id = 12;
SELECT `customer name` FROM customers WHERE cat_id = 12 ORDER BY cat_id;
SELECT * FROM sales WHERE amount > 200.
the query will display all the sales records with amounts starting from 200 and above
the query will display all the sales records with amounts less than 200
the query will display all the sales records with amounts greater than 200
the query will output sales records with the amount equal to 200.
Which of the following is not a relational operator?
&&
>=
!=
=
Correct command to create database school
use school ;
make database school ;
create school;
Create database school;
Which operator is used to match column values against a list of values?
between
IN
Like
Is Null
What could be the correct datatype for 'H.NO. 234, SEC-14' data
Date
int
varchar
decimal
Which of the following is not a text function?
TRIM()
TRUNCATE()
LEFT()
MID()
Which of the following is not a numeric function?
MOD
SIGN
MID
POW
Which of the following is not a date function?
Month
Year
Now
Pow
Which of the following functions returns the position of a substring in a given string?
MID
INSTR
SUBSTR
CHAR
What will be printed by the given query?
SELECT LENGTH("WINNER");
7
6
8
9
What will be returned by the given query?
SELECT INSTR("INDIA", "DI");
2
3
-2
-3
What will be returned by the given query?
SELECT concat("It", "was", "ok");
"It was ok"
"Itwasok"
"Itwas ok"
"Tt wasok"
What will be returned by the given query?
SELECT sign(26);
1
-1
0
none
What will be returned by the given query?
SELECT truncate(15.79, -1), truncate(15.79, 0), truncate(15.79, 1);
15 15 15.7
10 15.7 15.9
10 15 15.7
10 10 15.9
What will be returned by the given query?
SELECT month('2020-05-11');
5
11
May
November
The functions that work with one row at a time are called __________________ functions
Multiple Row Functions
Group Functions
Single Row Functions
Aggregate Functions
Full form of API
Application Process Interchange
Application Programs Interchange
Application Process Interface
Application Programming Interface
Connector Library to connect MySQL with Python IDLE is
pymysql
mysql.connector
both a and b
none of these
To display all the databases of MySQL with the help of cursor mycursor , command will be
mycursor.execute("SHOW DATABASES")
mycursor.execute("DESC DATABASES")
mycursor.executes("SHOW DATABASES")
mycursor.execute("SHOW ALL DATABASES")
Correct the error if any
mycursor = mydb.cursor()
mycursor.execute("CREATE TABLE customers (name VARCHAR(25), 'address' VARCHAR(55))")
mycursor.execute('CREATE TABLE customers (name VARCHAR(25), 'address' VARCHAR(55))')
mycursor.execute("CREATE TABLE customers (name VARCHAR(25), address VARCHAR(55))')
mycursor.execute("CREATE TABLE customers (name VARCHAR(25), address VARCHAR(55));")
mycursor.execute("CREATE TABLE customers (name VARCHAR(25), address VARCHAR55))")
After inserting the data we need to issue
rollback
set autocommit
mycur.commit(1)
mycur.commit()
A key which allows unique or null values.
Unique
Null key
Primary key
Alternate key
MySQL suitable datatype to store images is _______.
Boolean
BLOB
LONGTEXT
SET
Which image is associated with MySQL Logo?
What will be printed by the given query?
SELECT LENGTH( " INFORMATICS PRACTICES");
21
22
23
24
Which SQL function is used to find the average value of any column?
Mean()
Avg()
Average()
Sum()
Which function will be used to remove only the trailing spaces from a string?
ltrim()
rtrim()
trim()
all
Which operator performs pattern matching?
Between Operator
Like Operator
Exists Operator
None of these
Which is not a relational database management system?
MySql
IBM DB2
Oracle
Windows
Insert, select, delete and update command are part of _______ language
PHP
SQL
HTML
C++
Which function is used to connect to MySql database?
mysqli_connect()
mysqli_close()
mysqli_query()
$con
_______ helps to execute the SQL query statements in PHP scripting language
mysqli_connect()
mysqli_close()
mysqli_query()
mysqli_connect_error()
What is used to close an existing opened database connection between PHP scripting and MySQL Database Server?
mysqli_connect()
mysqli_close()
mysqli_query()
mysqli_connect_error()
_________ a domain-specific language used in programming and designed for managing data held in a relational database management system
SQL
PHP
HTML
MySql
A _______is a request for data or information from a database table or combination of tables.
query
request
command
instruction
_________is an open-source relational database management system
SQL
PHP
HTML
MYSQL
A ______is an organized collection of data, generally stored and accessed electronically from a computer system.
Table
Database
MYSQL
DBMS
What will be the output of the following query:
Select round(59999.99,-2);
59999
59900
60000
59990
Select the appropriate command to insert rows in a table
INSERT INTO Customers(ID, FirstName, LastName) VALUES ('1', 'User', 'Test');
INSERTINTO Customers(ID, FirstName, LastName) VALUES ('1', 'User', 'Test');
INSERT Between Customers(ID, FirstName, LastName) VALUES ('1', 'User', 'Test');
None of them
____________ command is same as Undo Command
Save
Roll Back
Commit
None of them
Select * from student ;
Above command gives output :
All rows and columns of table student
Selected Rows and columns
All table of Database
Nothing
Write a command to list the name of students with their marks from student table ;
Select * from student
Select all from student
Select Name , Marks from student ;
Select Name , marks with student;
Which of the following function concatenates the first character value to second character value
INSTR()
CHAR()
TRIM()
CONCAT()
Insert the missing statement to get all the columns from the Customers table.
___________________ * from Coustmer.
Insert
select
Update
None of them
What commands should you used in order to scroll through previously entered commands in MySQL?
tab key
arrow keys
up and down arrow keys
num keys
If you are going to use a new database named as studtbl, how do you select it?
SELECT studbl;
USE studtbl;
SELECT DATABASE studtbl;
SELECT * studbl;
What is the command to view ALL available databases?
SHOW ALL;
SELECT DATABASE();
SHOW DATABASE;
SHOW DATABASES;
tells MySQL to go ahead and add the next available number to the id field.
data type
default value
auto_increment
not null
Which clause is used with an "aggregate" function?
GROUP BY
SELECT
WHERE
Both GROUP BY and WHERE
What is the meaning of "GROUP BY" clause?
Group data by column values
Group data by row values
Group data by column and row values
None of the mentioned
How to select number of employees - department wise from Emp table (EmpNo, DeptNo, EmpName)?
Select empno, count(*) from Emp Group By deptno;
Select deptno, count(*) from Emp Group By deptno;
Select empno, count(*) from Emp Order By deptno;
Select deptno, count(*) from Emp Order By deptno;
How to select Maximum Salary of Employee from each Department in Emp table(empno, ename, deptno, sal)?
Select deptno, sal from Emp Group By deptno Order By Max(Sal);
Select deptno, sal from Emp Group By deptno having sal = max(sal);
Select deptno, max(sal) from Emp Group By deptno;
Select deptno, max(sal) from Emp Order By Max(Sal);
Which of the following is correct to count the total salary dept wise where there are more than two employees in a dept from emp table (empno, ename, deptno, sal)
SELECT deptno, sum(sal) As totalsal FROM emp GROUP BY deptno HAVING COUNT(empno) = 2
SELECT deptno, sum(sal) As totalsal FROM emp where COUNT(empno) = 2 GROUP BY deptno
SELECT deptno, sum(sal) As totalsal FROM emp GROUP BY deptno HAVING COUNT(empno) > 2
SELECT deptno, sum(sal) As totalsal FROM emp where COUNT(empno) > 2 GROUP BY deptno
Which clause is used to remove a foreign key constraint?
REMOVE
DELETE
DROP
EXCLUDE
Which keyword is used to specify the foreign key after the table is created?
UPDATE
ALTER TABLE
MODIFY
CHANGE
Which of the following is true about the HAVING clause?
Similar to the WHERE clause but is used for columns rather than groups.
Similar to WHERE clause but is used for rows rather than columns.
Similar to WHERE clause but is used for groups rather than rows.
Acts exactly like a WHERE clause.
The property that enforces foreign key relationships stay intact is called _____________
atomicity
durability
consistency
referential integrity
Which clause names the parent table and the index columns in the table?
REFERENCES
ON DELETE
CONSTRAINT
FOREIGN KEY
A. Performance B. Atomicity C. Consistency D.Isolation E.Durability
The ______ keyword returns all records from the right table (table2), and the matching records (if any) from the left table (table1).
INNER JOIN
RIGHT JOIN
EQUI JOIN
NATURAL JOIN
What is meaning of LIKE '%O%o%' ?
Feature begins with two O's
Feature ends with two o's
Feature has more than two o's
Feature has two O's in it, at any position
A table has 3 columns. student_id, name, department. I need to insert only student_id and name. Which command is true
insert into patient values(101,'Poorva')
insert into patient(student_id,name) values(101,'Poorva')
insert into patient(student_id,name) = (101,'Poorva')
insert into patient values(101,'Poorva','')
Not equal to?
>=
<>
=<
<=
How do we select all rows for the "Designer" table?
SELECT * FROM Designer
SELECT [All] FROM Designer
SELECT Designer.*
SELECT FROM Designer
There is no difference between a left join and a right join.
A left join returns all rows from the left table and matching rows from the right table, while a right join returns all rows from the left table and matching rows from the right table.
A left join returns all rows from the left table and matching rows from the right table, while a right join returns all rows from the right table and matching rows from the left table.
A left join returns only matching rows from the left table and the right table, while a right join returns only matching rows from the right table and the left table.
What is the result of the following SQL query: SELECT * FROM orders ORDER BY date DESC LIMIT 5;
All orders will be returned in reverse chronological order.
The 5 most recent orders will be returned in chronological order.
The 5 oldest orders will be returned in chronological order.
The 5 most recent orders will be returned in reverse chronological order.
Which of the following SQL queries performs an equi join?
SELECT * FROM customers JOIN orders ON customers.id = orders.customer_id;
SELECT * FROM employees JOIN departments ON employees.department_id = departments.id;
SELECT * FROM products LEFT JOIN categories ON products.category_id = categories.id;
SELECT * FROM sales RIGHT JOIN products ON sales.product_id = products.id;
Which operator is used to select values within a range?
RANGE
BETWEEN
WITHIN
What is the most common type of join?
INNER JOIN
INSIDE JOIN
JOINED
JOINED TABLE
Select mod(20,3)
6
2
3
5
Select round ( 167 . 89)
168
167
167.9
167.88
Select round ( 435. 75 , 1);
435.7
436
435.8
435
Select round ( 854. 34 , 1) ;
854
854. 4
854.3
Select round ( 1654 . 784, 2) ;
1654.79
1654.78
1654.7
1654.8
Select round ( 873 . 873 , 2) ;
873.87
873.88
873
874
Select round(345 . 78 , -1) ;
345.8
300
345
340
Select round ( 764 . 77 , -2 ) ;
760
770
700
800
Select round (823 . 65 , -2) ;
900
800
820
830
Select pow ( 3, 4 )
12
81
16
72
Select pow ( -3 , 2) ;
-9
9
6
-6
