-
CREATE
Used to create a table or database
Syntax:CREATE DATABASE DatabaseName
Ex: CREATE DATABASE School
Syntax:CREATE TABLE TableName
Ex: CREATE TABLE Student -
ALTER
Used to change the structure of the table
-
Add a new column
Syntax:ALTER TABLE TableName ADD ColumnName datatype(value)
Ex: ALTER TABLE Student ADD age NUMBER(2) -
Remove an existing column
Syntax:ALTER TABLE TableName DROP COLUMN ColumnName
Ex: ALTER TABLE Student DROP COlUMN address -
Rename the existing column
Syntax:ALTER TABLE TableName RENAME COLUMN oldColumnName TO newColumnName
Ex: ALTER TABLE Student RENAME COLUMN email TO emailid -
Increase or decrease the column size
Syntax:ALTER TABLE TableName MODIFY ColumnName datatype(newValue)
Ex: ALTER TABLE Student MODIFY emailid VARCHAR(30) -
Change the column data type
Syntax:ALTER TABLE TableName MODIFY ColumnName datatype
Ex: ALTER TABLE Student MODIFY DateofBirth year
-
-
TRUNCATE
Removes all the rows from the table
Syntax:TRUNCATE TABLE TableName
Ex: TRUNCATE TABLE Student -
DROP
Drops the entire table structure
Syntax:DROP TABLE TableName
Ex: DROP TABLE Student
-
INSERT
Insert rows to tables
Syntax:INSERT INTO TableName(column1, column2,...) VALUES(value1, value2,...)
Ex: INSERT INTO Student(RollNo, Name, Age) VALUES (1, 'Srishti', 21) -
UPDATE
Modify existing rows in a table
Syntax:UPDATE TableName SET ColumnName = value [WHERE condition]
Ex: UPDATE Student SET Age = 22 WHERE RollNo = 1; -
SELECT
Used to retrieve rows from a database or a table
Syntax:SELECT ColumnName FROM TableName
Ex: SELECT Name FROM Student -
DELETE
Remove existing rows from the table
Syntax:DELETE FROM TableName [WHERE condition]
Ex: DELETE FROM Student WHERE RollNo = 3;
-
GRANT
Gives users access privileges to the database
-
REVOKE
Withdraws the user’s access privileges given by using the GRANT command
-
COMMIT
Commits a transaction
-
ROLLBACK
Rollbacks a transaction in case of any error occurs
-
SAVEPOINT
Sets a savepoint within a transaction