0% found this document useful (0 votes)
4 views3 pages

My SQL

Uploaded by

pchetry2000
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

My SQL

Uploaded by

pchetry2000
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1-Mark Questions

1. What is the full form of RDBMS?


Relational Database Management System.
2. Who were the developers of MySQL?
Michael Widenius, David Axmark, and Allan Larsson.
3. What is the syntax to create a database in MySQL?
CREATE DATABASE [IF NOT EXISTS] database_name;
4. Name any two data types supported by MySQL.
INT, VARCHAR.
5. Which command is used to display the structure of a table in MySQL?
DESCRIBE table_name; or DESC table_name;
6. Define the term "primary key."
A primary key is a column that uniquely identifies each row in a table.
7. What is the use of the SELECT command in MySQL?
It is used to fetch data from a database.
8. Which MySQL keyword is used to eliminate duplicate values in a query result?
DISTINCT.
9. What is the default sorting order in MySQL?
Ascending (ASC).
10. Name any one arithmetic operator used in MySQL.
+ (Addition).
11. What is the purpose of the WHERE clause in a query?
It specifies the conditions for data retrieval.
12. How can you permanently delete a table in MySQL?
Using the DROP TABLE table_name; command.
13. Write the command to rename an existing table in MySQL.
ALTER TABLE old_table_name RENAME TO new_table_name;
14. What is the function of the NOT NULL constraint?
It ensures that a column cannot have a NULL value.
15. Which wildcard symbol is used to match any single character in a pattern?
_ (underscore).

2-Mark Questions

1. Differentiate between DDL and DML commands.


o DDL (Data Definition Language) deals with schema, like creating or
modifying tables (CREATE, ALTER).
o DML (Data Manipulation Language) deals with data, like inserting or
updating rows (INSERT, UPDATE).
2. Write the command to add a new column named "Grade" to an existing table
"Student."
ALTER TABLE Student ADD Grade CHAR(1);
3. Explain the use of DISTINCT in a SELECT query with an example.
DISTINCT is used to retrieve unique values.
Example: SELECT DISTINCT Section FROM Student;
4. Write a query to display all records where TotalMarks is greater than 400.
SELECT * FROM Student WHERE TotalMarks > 400;
5. What are the rules for naming a table in MySQL?
o Begin with an alphabet.
o Can include letters (A-Z, a-z), digits (0-9), and underscores (_).
o Should not exceed 30 characters.
o Reserved keywords are not allowed.
6. Explain the purpose of the ALTER TABLE command.
It modifies the structure of a table by adding, deleting, or renaming columns or
constraints.
7. Write the syntax for the BETWEEN clause in MySQL.
SELECT * FROM table_name WHERE column_name BETWEEN lower_limit AND
upper_limit;
8. What is the difference between CHAR and VARCHAR data types?
o CHAR: Fixed-length storage.
o VARCHAR: Variable-length storage.
9. How can you modify the data type of an existing column in a table?
ALTER TABLE table_name MODIFY column_name new_data_type;
10. Write a query to calculate the average of marks stored in a column TotalMarks.
SELECT AVG(TotalMarks) FROM Student;

3-Mark Questions

1. Explain the steps to start MySQL and connect to the server.


o Open MySQL Command Line Client.
o Enter the password when prompted.
o The prompt changes to mysql>, indicating a successful connection.
2. Write a query to create a table "Employee" with columns EmpID, Name, Salary,
and JoinDate (include appropriate data types and constraints).

CREATE TABLE Employee (


EmpID INT PRIMARY KEY,
Name VARCHAR(50) NOT NULL,
Salary FLOAT NOT NULL,
JoinDate DATE
);

3. Differentiate between TRUNCATE and DELETE commands.


o TRUNCATE: Removes all rows and resets auto-increment counters. Cannot be
rolled back.
o DELETE: Removes specific rows based on conditions. Can be rolled back.
4. How can you insert multiple records into a table in a single query? Provide an
example.

INSERT INTO Student (RollNo, Name, Class, Section, TotalMarks)


VALUES
(1, 'Amit', 10, 'A', 450),
(2, 'Rita', 10, 'B', 400),
(3, 'John', 10, 'A', 420);

5. Write the syntax and an example for the ALTER TABLE command to delete a
column.
ALTER TABLE table_name DROP column_name;

Example:

ALTER TABLE Student DROP Grade;

6. Explain the difference between DROP DATABASE and DELETE FROM.


o DROP DATABASE: Deletes the entire database including all its tables.
o DELETE FROM: Deletes rows from a specific table without affecting its
structure.
7. Write a query to retrieve the names of all students from a table Student who
belong to section 'A'.

SELECT Name FROM Student WHERE Section = 'A';

You might also like