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

Syntax

The document outlines SQL commands for database management, including creating, using, and deleting databases and tables. It details commands for altering tables, inserting values, updating data, and deleting specific rows. Each command is accompanied by its syntax and purpose for clarity.

Uploaded by

sreekutt987
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)
6 views2 pages

Syntax

The document outlines SQL commands for database management, including creating, using, and deleting databases and tables. It details commands for altering tables, inserting values, updating data, and deleting specific rows. Each command is accompanied by its syntax and purpose for clarity.

Uploaded by

sreekutt987
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

SYNTAX USES

CREATE DATABASE<DATABASE_NAME>; Used to create a database

USE <DATABSE_NAME>; Used to open a database

DROP DATABASE <DATABASE_NAME>; Used to delete a database along with all


its tables

CREATE TABLE <TABLE_NAME> Used to create a table


(
<COLUMN_NAME1> <DATA_TYPE>,(constraints if any)
<COLUMN_NAME2> <DATA_TYPE>,
<COLUMN_NAME3> <DATA_TYPE>,
<COLUMN_NAME4> <DATA_TYPE>
);

SHOW TABLE; Used to show the tables in a database

DESCRIBE <TABLE_NAME>; Used to view a table structure


OR
DESC <TABLE_NAME>;

ALTER COMMANDS

ALTER TABLE <TABLE_NAME> ADD(<COLMN_NAME> Adding a column to an existing table


<DATA_TYPE>SIZE);

Modifying an existing column


ALTER TABLE <TABLE_NAME> MODIFY(COLUMN_NAME
<DATA_TYPE>);

ALTER TABLE <TABLE_NAME> Renaming a column


CHANGE <OLD-COLUMN_NAME> <NEW COLUMN_NAME>
DATA TYPE ;

ALTER TABLE <TABLE_NAME> Removing a column


DROP <COLUMN_NAME>;

DROP TABLE <TABLE_NAME>; Used to delete a table permanently


SYNTAX USES

INSERT INTO TABLE_NAME Used to insert values/datas into


VALUES(value1,value,value3,etc…); table

INSERT INTO TABLE_NAME (column1,column2,column3,....) Used to insert data by


VALUES(value1,value2,value3,...); specifying both column names
and values into a table

INSERT INTO <TABLE_NAME> (column1,column2,column3,....) Used to insert data by


VALUES(value1,value2,value3,...); specifying column of a table

Modifying data in a table


UPDATE <TABLE_NAME>
SET
<COLUMN_NAME>=<VALUE1>,<COLUMN_NAME>=<VALUE2>,...
WHERE<COLUMN_NAME>=<NEW_VALUE>;

DELETE FROM <TABLE_NAME> WHERE <CONDITION>; Used to delete specific rows


from a table

You might also like