0% found this document useful (0 votes)
18 views

DB - Lab 1

SQL is a language used to create, manipulate, and retrieve data from a database. The document outlines several common SQL commands: CREATE is used to create tables and views; DESC describes a table's structure; INSERT adds rows of data to tables; SELECT retrieves data from one or more tables; and COMMIT permanently saves changes made to the database. Examples are provided for each command to demonstrate their proper syntax and usage.

Uploaded by

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

DB - Lab 1

SQL is a language used to create, manipulate, and retrieve data from a database. The document outlines several common SQL commands: CREATE is used to create tables and views; DESC describes a table's structure; INSERT adds rows of data to tables; SELECT retrieves data from one or more tables; and COMMIT permanently saves changes made to the database. Examples are provided for each command to demonstrate their proper syntax and usage.

Uploaded by

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

SQL (Structured Query Language)

1. Command Name :- create


Description:- It is used to create table, view,index.

Syntax:- Create table tablename(column1 datatype(size), column2 datatype(size) .. . . . . . . . .(columnN


datatype (size));

Example:- create table student (name char(30) , regdno number(10) , branch char(20) ) ;

Output:- Table created.

2. Command Name:- desc

Syntax : desc tablename ;

Example: desc student ;

Description:- It describes structure or schema of a table.

Output :-
Table Column Data Type Length Precision
STUDENT NAME Char 30 -
REGDNO Number - 10
BRANCH Char 20 -

3. Command Name:- insert

Description:- I t is used to insert data into table or view or index.

Syntax: - insert into tablename values (value1,value2,….value n);

Examples:-
insert into student values (’abhaya’, 1901229015 , ’CSE’ );

Output:-1 row created.

insert into student values (’abhilash’, 1901229016 , ’CSE’ );

Output:- 1 row created.

insert into student values (’abhishek’, 1901229017 , ’CSE’ );

1 row created.

insert into student values (’abhishek’, 1901229018 , ’CSE’ );

Output:- 1 row created.

insert into student values (’aditya’, 1901229019, ’CSE’ );


Output:- 1 row created.

1
4. Command Name:- select

Syntax:- select column1,column2,…………,column1n from tablename;

Description:- It is used to display records/column values of a table.

Example1:- select * from student;

OR

select name,regdno,branch from student;

Output:- NAME REGDNO BRANCH


abhaya 1901229015 CSE
abhilash 1901229016 CSE
abhishek 1901229017 CSE
abhishek 1901229018 CSE
aditya 1901229019 CSE

Example2:- select distinct name from student;


Description: It display distinct names.

Output:- NAME
abhaya
abhilash
abhishek
aditya

In the above output, Name is displayed by removing duplicate values.

5. Command Name:- commit

Description: It is used to save the data permanently to database.

Example:- commit;

Output:- Commit statement not applicable. All statements are automatically committed .

You might also like