0% found this document useful (0 votes)
3 views2 pages

SQL

The document outlines CRUD operations for managing a College database, including SQL commands for creating tables and inserting data. It also explains key SQL concepts such as the differences between DELETE, TRUNCATE, and DROP statements, as well as the subsets of SQL: DDL, DML, DCL, and TCL. Additionally, it provides examples of SQL queries for retrieving specific data from an employee table.

Uploaded by

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

SQL

The document outlines CRUD operations for managing a College database, including SQL commands for creating tables and inserting data. It also explains key SQL concepts such as the differences between DELETE, TRUNCATE, and DROP statements, as well as the subsets of SQL: DDL, DML, DCL, and TCL. Additionally, it provides examples of SQL queries for retrieving specific data from an employee table.

Uploaded by

18 Gaurav Lone
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

//CRUD Operations

CREATE DATABASE College;

1.create table table_name (

column_name1 datatype constraint,


column_name2 datatype constraint,
column_name3 datatype constraint,
)

eg: create table student(


id int primary key,
name varchar(30),
age int NOT NULL
);

insert into student values(1,'gaurav',25)


insert into student (rollno,name) values (121,gaurav),(122,Tejas);

//SQL Interview Questions

1.what is the difference between delete and truncate and drop statement ?
DELETE
| | TRUNCATE
| DROP
-> delete command is used to delete row in a table
Truncate delete's all the rows from the table
Deletes the table
You can rollback after using delete statement
You cannot rollback.
You cannot rollback.
It is a DML command
It is a DDL command.

2.What are the different subset of SQL?


->1.Data Definition Language (DDL):
Purpose: To define and manage database structure.
Key Commands:
CREATE: To create tables, databases, indexes, etc.
ALTER: To modify existing database objects like tables.
DROP: To delete tables or databases.
TRUNCATE: To remove all records from a table, but keep the structure.
CREATE TABLE students (ID INT, Name VARCHAR(100));

2.Data Manipulation Language (DML):


Purpose: To manipulate data stored in the database.
Key Commands:
INSERT: To add new records.
UPDATE: To modify existing records.
DELETE: To remove records.
INSERT INTO students (ID, Name) VALUES (1, 'John Doe');

3.Data Control Language (DCL):


Purpose: To control access to data and manage permissions.
Key Commands:
GRANT: To give privileges to users.
REVOKE: To take back privileges.
GRANT SELECT ON students TO user_name;

4.Transaction Control Language (TCL):


Purpose: To manage transactions in the database.
Key Commands:
COMMIT: To save the changes made by DML commands.
ROLLBACK: To undo changes if a transaction fails.
SAVEPOINT: To set a point in a transaction to which you can later roll
back.
BEGIN TRANSACTION;
INSERT INTO students (ID, Name) VALUES (2, 'Jane Doe');
COMMIT;

3.display employee that begin with A?


-> select * from employee where name like A%;

4.Third highest salary from employee table?


->select * from employee where sal = (select sal from employee where sal<(select
max(sal) from employee));

5.2nd largest salary from employee


->

6.ACID properties in DBMS

You might also like