Professional Documents
Culture Documents
SQL Cheat Sheet PDF
SQL Cheat Sheet PDF
SQL stands for Structured Query Language Data Query Language (DQL)
SQL is pronounced sequel SELECT - Retrieve data from table(s)
SQL is declarative language Data Manipulation Language (DML)
SQL is used to access & manipulate data in databases INSERT - Insert data into db table
Top SQL DBs are MS SQL Server, Oracle, DB2, and MySQL UPDATE - Update data in db table
DELETE - Delete data from table
Database Definitions
Data Definition Language (DDL)
RDBMS (Relational Database Management System)
CREATE - Create db object (table, view, etc.)
Software that stores and manipulates data arranged in
ALTER - Modify db object (table, view, etc.)
relational database tables.
DROP - Delete db object (table, view, etc.)
Table A set of data arranged in columns and rows. The
columns represent characteristics of stored data and the Data Control Language (DCL)
rows represent actual data entries. GRANT - Assign privilege
REVOKE - remove privilege
How to select data from more than one table Using UNION
SELECT <Column List> SELECT <Column List> FROM <Table1>
FROM <Table1> JOIN <Table2> UNION
ON <Table1>.<Column1> = <Table2>.<Column1> SELECT <Column List> FROM <Table2>
Example: Example:
SELECT Orders.LastName, Countries.CountryName SELECT FirstName, LastName FROM Orders2010
FROM Orders JOIN Countries ON UNION
Orders.CountryID = Countries.ID SELECT FirstName, LastName FROM Orders2011
CREATE TABLE
CREATE TABLE <Table Name> CREATE TABLE Orders
( Column1 DataType, ( FirstName CHAR(100),
Column2 DataType, LastName CHAR(100),
Column3 DataType, OrderDate DATE,
. ) OrderValue Currency )
http://www.SQL-Tutorial.net