SQL Quick Reference For Beginners
SQL Quick Reference For Beginners
b. ALTER:
It is used to alter the structure of the database.
Syntax:
To add a new column in the table:
ALTER TABLE table_name ADD (column_name
COLUMN-definition);
To modify existing column in the table:
d. TRUNCATE:
It is used to delete all the rows from the table and
free the space containing the table.
Syntax:
INSERT
UPDATE
DELETE
a. INSERT:
This statement is used to insert data into the row of
a table.
Syntax:
c. DELETE:
This command is used to remove one or more row
from a table.
Syntax:
DELETE FROM table_name
WHERE some_condition;
3. DCL(Data Control Language)
Grant
Revoke
a. GRANT:
This command gives users access privileges to the
database.
Syntax:
GRANT SELECT, UPDATE ON MY_TABLE TO
SOME_USER, ANOTHER_USER;
b. REVOKE:
This command withdraws the user’s access
privileges given by using the GRANT command.
Syntax:
REVOKE SELECT, UPDATE ON MY_TABLE FROM
USER1, USER2;
4. TCL(Transaction Control Language)
COMMIT
ROLLBACK
SAVEPOINT
a. COMMIT:
Commit command is used to save all the transactions
to the database.
Syntax:
COMMIT;
b. ROLLBACK:
Rollback command is used to undo transactions that
have not already been saved to the database.
Syntax:
ROLLBACK;
c. SAVEPOINT:
It is used to roll the transaction back to a certain
point without rolling back the entire transaction.
Syntax:
SAVEPOINT SAVEPOINT_NAME;
5. DQL(Data Query Language)
SELECT
a. SELECT:
This command is used to retrieve data from the
database
Syntax: