


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



CREATE TABLE syntax DDL - โโ-CREATE TABLE tableName ( colName dataType constraint INDEX indexName (colName) PRIMARY KEY (colName, colName) or colName dataType PRIMARY KEY FOREIGN KEY (colName, colName) REFERENCES tableName (colName) ); CREATE INDEX syntax DDL - โโ-CREATE [UNIQUE] INDEX indexName ON tableName (colName); UNIQUE should only be used on a column that should not have duplicate values. DROP INDEX syntax DDL - โโ-DROP INDEX indexName; DROP INDEX 'PRIMARY' ON tableName; drops PK ALTER INDEX DDL - โโ-ALTER INDEX indexName ON tableName (colName, colName);
INSERT command syntax DML - โโ-INSERT INTO tableName VALUES (val1, val2, val3...); For inserting new rows into existing table. UPDATE syntax DML - โโ-UPDATE tableName SET colName = expression {ex. PRICE = 4.00} WHERE condition; {ex. S_NUMBER = A123} For modifying data in a table DELETE syntax DML - โโ-DELETE FROM tableName WHERE condition; {ex. PRICE > 3.00} For deleting rows from a table ALTER TABLE syntax DDL - โโ-ALTER TABLE tableName ADD (colName, dataType); or ALTER TABLE tableName ADD INDEX indexName (colName); or ALTER TABLE tableName ADD PRIMARY KEY (colName); or ALTER TABLE tableName ADD FOREIGN KEY (colName)
Creates DB if it does not already exist DDL - โโ-CREATE DATABASE IF NOT EXISTS dbName CREATE VIEW DDL - โโ-CREATE VIEW viewName AS SELECT query FROM tableName; Changing a VIEW DDL - โโ-ALTER VIEW Subquery DML - โโ-SELECT colName FROM tableName WHERE colName = (SELECT colName FROM tableName WHERE condition); ANALYZE stats - โโ-ANALYZE TABLE tableName COMPUTE STATISTICS;