DDL DML Commands
DDL DML Commands
DDL DML Commands
fields.
SQL Constraints
1. NOT NULL : Ensures that a column cannot have NULL value.
2. Primary Key : Used to uniquely identify a row in the table.
Creating Databases
Create database [If not Exists] <database name>;
Opening Databases
Use <databasename>
Removing Databases
Drop database <databasename>;
e.g.,
Create table student(Sname varchar(10) not null,GRNO int primary key, Class int
not null, Section char(2));
To view the structure of the table
Desc <tablename>;
Inserting Dates
The format to insert date is ‘yyyy-mm-dd’.
Modifying Data with UPDATE command
• Sometimes you need to change some or all of the values in an existing column.
This can be done using UPDATE command.
• The UPDATE command specifies the rows to be changed using the WHERE
clause, and the new data using the SET keyword.
Syntax: UPDATE <tablename> SET <columnname>=<new value> WHERE
<condition>;
Here condition is optional.
Deleting data from table using DELETE Command
• Rows can be removed from the given table using DELETE command.
• This command will remove the entire rows which satisfy the given condition,
not selected fields from the table.
Syntax : DELETE FROM <tablename> WHERE <condition>;
Condition is optional.