SQL

Card Set Information

Author:
TxMxT
ID:
254284
Filename:
SQL
Updated:
2013-12-26 11:12:54
Tags:
SQL
Folders:
SQL,Quick,Reference
Description:
SQL Quick Reference
Show Answers:

Home > Flashcards > Print Preview

The flashcards below were created by user TxMxT on FreezingBlue Flashcards. What would you like to do?


  1. Select
    • SELECT column_name(s)
    • FROM table_name
  2. AND / OR
    • SELECT column_name(s)
    • FROM table_name
    • WHERE condition
    • AND|OR condition
  3. ALTER TABLE
    ALTER TABLE table_name ADD column_name datatype

    or

    ALTER TABLE table_name DROP COLUMN column_name
  4. AS (alias)
    SELECT column_name AS column_aliasFROM table_name

    or

    SELECT column_nameFROM table_name  AS table_alias
  5. BETWEEN
    • SELECT column_name(s)
    • FROM table_name
    • WHERE column_name
    • BETWEEN value1 AND value2
  6. CREATE DATABASE
    CREATE DATABASE database_name
  7. CREATE TABLE
    • CREATE TABLE table_name
    • (
    • column_name1 data_type,
    • column_name2 data_type,
    • column_name2 data_type,
    • ...)
  8. CREATE INDEX
    • CREATE INDEX index_name
    • ON table_name (column_name)

    or

    • CREATE UNIQUE INDEX index_name
    • ON table_name (column_name)
  9. CREATE VIEW
    • CREATE VIEW view_name AS
    • SELECT column_name(s)
    • FROM table_name
    • WHERE condition
  10. DELETE
    • DELETE FROM table_name
    • WHERE some_column=some_value

    or

    • DELETE FROM table_name 
    • (Note: Deletes the entire table!!)
    • DELETE * FROM table_name (Note: Deletes the entire table!!)
  11. DROP DATABASE
    DROP DATABASE database_name
  12. DROP INDEX
    • DROP INDEX table_name.index_name (SQL Server)
    • DROP INDEX index_name ON table_name (MS Access)
    • DROP INDEX index_name (DB2/Oracle)
    • ALTER TABLE table_name
    • DROP INDEX index_name (MySQL)
  13. DROP TABLE
    DROP TABLE table_name
  14. GROUP BY
    • SELECT column_name, aggregate_function(column_name)
    • FROM table_name
    • WHERE column_name operator value
    • GROUP BY column_name
  15. HAVING
    • SELECT column_name, aggregate_function(column_name)
    • FROM table_name
    • WHERE column_name operator value
    • GROUP BY column_name
    • HAVING aggregate_function(column_name) operator value
  16. IN
    • SELECT column_name(s)
    • FROM table_name
    • WHERE column_name
    • IN (value1,value2,..)
  17. INSERT INTO
    • INSERT INTO table_name
    • VALUES (value1, value2, value3,....)

    or

    • INSERT INTO table_name
    • (column1, column2, column3,...)
    • VALUES (value1, value2, value3,....)
  18. INNER JOIN
    • SELECT column_name(s)
    • FROM table_name1
    • INNER JOIN table_name2 
    • ON table_name1.column_name=table_name2.column_name
  19. LEFT JOIN
    • SELECT column_name(s)
    • FROM table_name1
    • LEFT JOIN table_name2 
    • ON table_name1.column_name=table_name2.column_name
  20. RIGHT JOIN
    • SELECT column_name(s)
    • FROM table_name1
    • RIGHT JOIN table_name2 
    • ON table_name1.column_name=table_name2.column_name
  21. FULL JOIN
    • SELECT column_name(s)
    • FROM table_name1
    • FULL JOIN table_name2 
    • ON table_name1.column_name=table_name2.column_name
  22. LIKE
    • SELECT column_name(s)
    • FROM table_name
    • WHERE column_name LIKE pattern
  23. ORDER BY
    • SELECT column_name(s)
    • FROM table_name
    • ORDER BY column_name [ASC|DESC]
  24. SELECT *
    • SELECT *
    • FROM table_name
  25. SELECT DISTINCT
    • SELECT DISTINCT column_name(s)
    • FROM table_name
  26. SELECT INTO
    • SELECT *
    • INTO new_table_name [IN externaldatabase]
    • FROM old_table_name

    or

    • SELECT column_name(s)
    • INTO new_table_name [IN externaldatabase]
    • FROM old_table_name
  27. SELECT TOP
    • SELECT TOP number|percent column_name(s)
    • FROM table_name
  28. TRUNCATE TABLE
    TRUNCATE TABLE table_name
  29. UNION
    • SELECT column_name(s) FROM table_name1
    • UNION
    • SELECT column_name(s) FROM table_name2
  30. UNION ALL
    • SELECT column_name(s) FROM table_name1
    • UNION
    • ALLSELECT column_name(s) FROM table_name2
  31. UPDATE
    • UPDATE table_name
    • SET column1=value, column2=value,...
    • WHERE some_column=some_value
  32. WHERE
    • SELECT column_name(s)
    • FROM table_name
    • WHERE column_name operator value

What would you like to do?

Home > Flashcards > Print Preview