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

SQL

SQL, or Structured Query Language, is a computer language used for storing, manipulating, and retrieving data in relational databases. It consists of five types of commands: DDL (Data Definition Language), DML (Data Manipulation Language), DCL (Data Control Language), TCL (Transaction Control Language), and DQL (Data Query Language), each serving specific functions in database management. Key DDL commands include CREATE, DROP, ALTER, and TRUNCATE, while DML commands include INSERT and UPDATE for modifying data.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
2 views3 pages

SQL

SQL, or Structured Query Language, is a computer language used for storing, manipulating, and retrieving data in relational databases. It consists of five types of commands: DDL (Data Definition Language), DML (Data Manipulation Language), DCL (Data Control Language), TCL (Transaction Control Language), and DQL (Data Query Language), each serving specific functions in database management. Key DDL commands include CREATE, DROP, ALTER, and TRUNCATE, while DML commands include INSERT and UPDATE for modifying data.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 3

SQL

SQL is Structured Query Language, which is a computer language for storing, manipulating and retrieving
data stored in relational database.

SQL Commands

SQL commands are instructions. It is used to communicate with the database. It is also used to perform
specific tasks, functions, and queries of data.

Types of SQL Commands

There are five types of SQL commands: DDL, DML, DCL, TCL, and DQL.

1. Data Definition Language (DDL)

DDL changes the structure of the table like creating a table, deleting a table (drop), altering a table,
etc.

 CREATE

It is used to create a new table in the database.

Syntax

CREATE TABLE table_name

(Column1 data type constraint,

Column2 data type constraint,

Column3 data type constraint,

..... column N data type constraint,

PRIMARY KEY ( one or more columns )

);

Ex: CREATE TABLE CUSTOMERS (

ID INT NOT NULL,

NAME VARCHAR (20) NOT NULL,

AGE INT NOT NULL,

ADDRESS CHAR (25) ,

SALARY DECIMAL (18, 2),

PRIMARY KEY (ID)

);
 DROP:
It is used to remove a table definition and all the data, indexes, triggers, constraints etc..

Syntax

DROP TABLE table_name;

Example

DROP TABLE EMPLOYEE;

 ALTER:
It is used to alter the structure of the database. This change could be either to modify the
characteristics of an existing attribute or probably to add a new attribute.

Syntax 1: To add a new column in the table

ALTER TABLE table_name ADD column_name COLUMN-definition;

EXAMPLE:

ALTER TABLE STU_DETAILS ADD(ADDRESS VARCHAR2(20))

Syntax 2: To modify existing column in the table

ALTER TABLE MODIFY(COLUMN DEFINITION....)

EXAMPLE:

ALTER TABLE STU_DETAILS MODIFY (NAME VARCHAR2(20))

 TRUNCATE:
It is used to delete all the rows from the table and free the space containing the table.

Syntax:

TRUNCATE TABLE table_name;

Example:

TRUNCATE TABLE EMPLOYEE;

2. Data Manipulation Language

DML commands are used to modify the database. It is responsible for all form of changes in the
database.
INSERT:

The INSERT statement is a SQL query. It is used to insert data into the row of a table.

Syntax:

INSERT INTO TABLE_NAME 2. VALUES (value1, value2, value3, .... valueN);

Example:

INSERT INTO java_point (Author, Subject) VALUES ("Sonoo", "DBMS");

 UPDATE:

This command is used to update or modify the value of a column in the table.

Syntax:

UPDATE table_name SET


column_name1= value1,
...
column_nameN = valueN
WHERE CONDITION

Example:

UPDATE students
SET User_Name = 'Sonoo' 3
WHERE Student_Id = '3

You might also like