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

Sql command

The document outlines SQL commands categorized into Data Definition Language (DDL), Data Manipulation Language (DML), and Data Control Language (DCL). DDL commands include CREATE and DROP for defining and deleting database structures, while DML commands such as SELECT, INSERT, DELETE, and UPDATE are used for manipulating records within those structures. Examples are provided for each command to illustrate their usage in creating databases and tables, as well as managing data within them.

Uploaded by

Emick Ghimire
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Sql command

The document outlines SQL commands categorized into Data Definition Language (DDL), Data Manipulation Language (DML), and Data Control Language (DCL). DDL commands include CREATE and DROP for defining and deleting database structures, while DML commands such as SELECT, INSERT, DELETE, and UPDATE are used for manipulating records within those structures. Examples are provided for each command to illustrate their usage in creating databases and tables, as well as managing data within them.

Uploaded by

Emick Ghimire
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Sql command

DDL DML and DCL statements

1) Data Definition Language (DDL)


DDL is used by database designer and programmer to specify the content and the structure of table. DDL
is used to define the physical characteristics of records in a database table. It includes command than
manipulate the structure of object such as table. Some DDL statements are: CREATE, DROP, ALTER

1.1 CREATE statement


In order to create a database we can use CREATE statement as follows:

CREATE DATABASE database_name;

Eg,

CREATE DATABASE student;

The above statement will create a database with the name student.

In order to create a database table we can use CREATE statement as follows:

CREATE TABLE table_name(col1 datatype, col2 datatype);

Eg,

CREATE TABLE student(SN Number, Fname Text);

The above statement will create a database table named student with two column SN and Fname. The
number of column can be increased accordingly.

1.2 DROP statement


It is used to delete database or table from the SQL server.

DROP DATABASE database_name;

Eg,

DROP DATABASE student;

This statement will delete database named student from the SQL server.

DROP TABLE table_name;

Eg,

DROP TABLE student;

This statement will delete database table named student from the SQL server.

2) Data Manipulation Language (DML)


DML is related with manipulation of records such as retrieval, sorting, displaying and deleting records or
data. It helps user to submit query and display report of the table. It provide technique for processing
the database. It includes commands like SELECT, INSERT, DELETE and UPDATE to manipulate the
information stored in the database.

2.1) SELECT statement

SELECT * FROM table_name;

Eg:

SELECT * FROM student;

This statement will select all the columns from the database table named student.

2.2) INSERT statement

INSERT INTO table_name(col1, col2...) VALUES (Value1, Value2...);

Eg,

INSERT INTO student(SN,Fname) VALUES (3,"Ram");

The above statement will insert 3 and Ram into the database table named student.

2.3) DELETE statement

DELETE FROM table_name WHERE condition;

Eg,

DELETE FROM student WHERE Fname = "Ram";

This statement will delete all the records from the student table where the Fname value is 'Ram'.

2.4) UPDATE statement

UPDATE table_name SET col1=value1, col2=value2, WHERE condition;

Eg,

UPDATE student SET SN=3, Fname = "Hari", WHERE Fname = "Ram";

You might also like