Appendix A. Common SQL Commands

This appendix details some of the most common SQL commands that you will use. As we have stated throughout the book, check your database documentation because some of the statements vary depending upon your implementation.

SQL Statements

ALTER TABLE TABLE_NAME [MODIFY | ADD | DROP]   [COLUMN COLUMN_NAME][DATATYPE|NULL NOT NULL] [RESTRICT|CASCADE] [ADD | DROP]  CONSTRAINT CONSTRAINT_NAME]

Description: Alters a table’s columns

COMMIT

COMMIT [ TRANSACTION ]

Description: Saves a transaction to the database

CREATE INDEX INDEX_NAME ON TABLE_NAME (COLUMN_NAME)

Description: Creates an index on a table

CREATE ROLE

Get SQL in 24 Hours, Sams Teach Yourself, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.