Advertisement
steijnb

SQL commands. Codecademy SQL Syntax

Sep 14th, 2015
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 2.36 KB | None | 0 0
  1. SQL:
  2. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  3. CREATE TABLE, CREATE a NEW TABLE.
  4. INSERT INTO, adds a NEW ROW TO a TABLE.
  5. SELECT, queries DATA FROM a TABLE.
  6. UPDATE, edits a ROW IN a TABLE.
  7. ALTER TABLE, changes an existing TABLE.
  8. DELETE FROM, deletes ROWS FROM a TABLE.
  9.  
  10. SELECT, IS the clause you every TIME you want query information FROM a DATABASE.
  11. WHERE, IS a popular command that lets you FILTER the RESULT OF the query based ON conditions that you specify.
  12. LIKE/BETWEEN, special operators that can be used IN a WHERE clause.
  13. AND/OR, special operators that you can USE WITH WHERE TO FILTER the query ON two OR more conditions.
  14. ORDER BY, lets you sort the RESULT OF the query IN either ascending(ASC) OR descending(DESC) ORDER.
  15. LIMIT, lets you specify the maximum NUMBER OF ROWS that the query will RETURN. This IS especially important IN LARGE TABLES that have thousands OR even millions OF ROWS.
  16.  
  17. COUNT, IS a FUNCTION that the name OF a COLUMN(s) AS an argument AND counts the NUMBER OF ROWS WHERE the VALUE(s) IS NOT NULL.
  18. GROUP BY, IS a clause used WITH aggregate functions TO combine DATA FROM one OR more COLUMNS.
  19. SUM(), IS a FUNCTION that takes the COLUMN name AS an argument AND RETURNS the SUM OF ALL VALUES IN that COLUMN.
  20. MAX(), IS a FUNCTION that takes the COLUMN name AS an argument AND RETURNS the largest VALUE IN that COLUMN.
  21. MIN(), IS a FUNCTION that takes the COLUMN name AS an argument AND RETURNS the smallest VALUE IN that COLUMN.
  22. AVG(), IS a FUNCTION that takes a COLUMN name AS an argument AND RETURNS the average VALUE FOR that COLUMN.
  23. ROUND(), IS a FUNCTION that takes two arguments, a COLUMN name AND the NUMBER OF DECIMAL places TO round the VALUES IN that COLUMN.
  24.  
  25. INNER JOIN, will combine ROWS FROM different TABLES IF the JOIN condition IS TRUE.
  26. LEFT OUTER JOIN, will RETURN every ROW IN the LEFT TABLE, AND IF the JOIN condition IS NOT met, NULL VALUES are used TO fill IN the COLUMNS FROM the RIGHT TABLE.
  27. AS, IS a keyword IN SQL that allows you TO RENAME a COLUMN OR TABLE IN the RESULT SET USING an alias.
  28.  
  29. PRIMARY KEY, IS a COLUMN that serves a UNIQUE identifier FOR ROW IN the TABLE. VALUES IN this COLUMN must be UNIQUE AND cannot be NULL.
  30. FOREIGN KEY, IS a COLUMN that contains the PRIMARY KEY TO another TABLE IN the DATABASE. It IS used TO identify a particular ROW IN the referenced TABLE.
  31.  
  32. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement