This document provides a quick reference to common SQL statements for creating, modifying, and querying data in database tables. It includes statements for creating tables, adding/dropping columns, inserting/updating/deleting rows, and selecting data with conditions, sorting, aggregation, and joins. Data types like integers, decimals, dates, and strings are also summarized for specifying column properties.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
63 views
SQL Quick Reference
This document provides a quick reference to common SQL statements for creating, modifying, and querying data in database tables. It includes statements for creating tables, adding/dropping columns, inserting/updating/deleting rows, and selecting data with conditions, sorting, aggregation, and joins. Data types like integers, decimals, dates, and strings are also summarized for specifying column properties.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1
SQL Quick Reference*
Create Table Statement Delete From Statement
CREATE TABLE table_name DELETE FROM table_name (column_1 data_type_for_column_1, WHERE {condition} column_2 data_type_for_column_2, QUERY STATEMENTS ... ) Select Statement Data Type Description SELECT column_name FROM table_name integer(size) Distinct int(size) Hold integers only. Optional number of digits can be specified in SELECT DISTINCT column_name smallint(size) parenthesis. FROM table_name tinyint(size) Where Hold numbers with fractions. Optional number of digits can be SELECT column_name decimal(size,d) numeric(size,d) specified in size. The number of digits to the right of the decimal is FROM table_name specified in d. WHERE condition char(size) Holds a fixed length string (can contain letters, numbers, and And/Or special characters). The fixed size is specified in parenthesis. SELECT column_name Holds a variable length string (can contain letters, numbers, and FROM table_name varchar(size) special characters). The maximum size is specified in parenthesis. WHERE simple condition Date Holds a date information {[AND|OR] simple condition} In Drop Table Statement SELECT column_name DROP TABLE table_name FROM table_name Truncate Table Statement WHERE column_name IN (value1, value2, ...) TRUNCATE TABLE table_name Between Alter Table Statement Add SELECT column_name ALTER TABLE table_name FROM table_name ADD column_name data_type WHERE column_name BETWEEN value1 AND value2 Alter Table Statement Drop Like ALTER TABLE table_name SELECT column_name DROP COLUMN column_name FROM table_name Alter Table Statement Change WHERE column_name LIKE PATTERN ALTER TABLE table_name Order By CHANGE old_column_name new_column_name SELECT column_name new_data_type FROM table_name Create Index [WHERE condition] CREATE [UNIQUE] INDEX index_name ORDER BY column_name [ASC, DESC] ON table_name (column_name [ASC, DESC]) Count Drop Index SELECT COUNT(column_name) DROP INDEX index_name FROM table_name RECORD MODIFICATION Group By Insert Into Statement SELECT column_name1, SUM(column_name2) INSERT INTO table_name (column1, column2, ...) FROM table_name VALUES (value1, value2, ...) GROUP BY column_name1 Update Statement Having UPDATE table_name SELECT column_name1, SUM(column_name2) SET column_1 = new_value FROM table_name WHERE {condition} GROUP BY column_name1 HAVING (arithmetic function condition) *based on MySQL syntax