+ All Categories
Home > Documents > For a Further Description of SQL Functionality Please Click the Links at the Far Left on This Page.

For a Further Description of SQL Functionality Please Click the Links at the Far Left on This Page.

Date post: 30-May-2018
Category:
Upload: watasedere
View: 221 times
Download: 0 times
Share this document with a friend

of 23

Transcript
  • 8/9/2019 For a Further Description of SQL Functionality Please Click the Links at the Far Left on This Page.

    1/23

    This SQL Syntax Reference page shows the syntax for each feature described in the SQL Tutorial. Itprovides a Quick Reference to SQL.

    For a further description of SQL functionality, please click the links at the far left on this page.

    SQL Basics SQL Administration SQL Advanced

    SQL SELECTSQL WHERE

    SQL INSERT

    SQL UPDATE

    SQL DELETESQL CREATE DATABASE

    SQL DROP DATABASE

    SQL CREATE TABLESQL ALTER TABLE

    SQL DROP TABLE

    SQL CREATE INDEXSQL DROP INDEX

    SQL ADD FOREIGN KEY

    SQL DROP FOREIGN KEYSQL CREATE VIEW

    SQL DROP VIEW

    SQL CONCAT

    SQL SUBSTRINGSQL TRIM

    SQL AND & OR

    SQL INSQL BETWEEN

    SQL LIKE

    SQL DISTINCTSQL GROUP BY

    SQL AGGREGATE

    SQL HAVING

    SQL ORDER BYSQL JOIN

    SQL OUTER JOIN

    SQL Syntax and Conventions

    SQL statements are represented as text.

    SQL statements have keywords that must be spelled following rules. The keywords can be upper or

    lower case - SQL is not case sensitive. By convention and to improve readability, this tutorial spellsSQL keywords in upper case.

    SQL statements are independent of text lines. A single SQL statement can be placed on one text line or

  • 8/9/2019 For a Further Description of SQL Functionality Please Click the Links at the Far Left on This Page.

    2/23

    on multiple. In addition, multiple SQL statements can be combined on a single text line. By convention

    and to improve readability, this tutorial does not put more than one SQL statement on a single text line.

    Further, SQL statements are often broken into multiple lines.

    A SQL statements may be terminated by a semi-colon or the word 'GO'. This tutorial leaves these

    terminators out. Please supply as needed.

    SQL BASICS

    SQL SELECT Syntax

    SELECT

    FROM

    SQL WHERE Clause Syntax

    WHERE

    Each condition tests column(s) using comparison operator(s). The following basic comparisonoperators are supported:

    Operator Description

    =Equal

    Not Equal>

    Greater Than

    =

    Greater Than Or Equal

  • 8/9/2019 For a Further Description of SQL Functionality Please Click the Links at the Far Left on This Page.

    3/23

    INSERT INTO ( )

    VALUES ()

    SQL UPDATE Syntax

    UPDATE

    SET = WHERE

    SQL DELETE Syntax

    DELETE FROM WHERE

    SQL ADMINISTRATION

    SQL CREATE DATABASE Syntax

    CREATE DATABASE

    SQL DROP DATABASE Syntax

    DROP DATABASE

    SQL CREATE TABLE Syntax

    CREATE TABLE (

    )

    The number of characters that can make up SQL table names and column names varies by DBMS. Inmany cases the limit is 30 characters. The leading character of the name must be alphabetic - not a

    number or special character. The name of a new table can not duplicate the name of an existing table

    and should not be the same as a SQL reserved word. The underscore character can be used to improvereadability. The same column name can not be repeated within a table. List elements are seperated by

    commas.

  • 8/9/2019 For a Further Description of SQL Functionality Please Click the Links at the Far Left on This Page.

    4/23

    Here are some example datatypes:

    SQL Datatype Description

    integer(size)int(size)

    smallint(size)

    tinyint(size) Integersdecimal(size,decimals)

    numeric(size,decimals) Numbers with decimals

    char(size) Fixed length character stringvarchar(size) Variable length character string

    date A date in yyyymmdd format

    SQL ALTER TABLE Syntax

    ALTER TABLE ADD

    ALTER TABLE

  • 8/9/2019 For a Further Description of SQL Functionality Please Click the Links at the Far Left on This Page.

    5/23

    ALTER COLUMN

    ALTER TABLE DROP COLUMN

    SQL DROP TABLE Syntax

    DROP (

    SQL CREATE INDEX Syntax

    CREATE INDEX ON (

    ,

    ,)

    CREATE UNIQUE INDEX ON (

    ,

    ,

    )

    The number of characters that can make up SQL names for tables, columns and indexes varies by

    DBMS. In many cases the limit is 30 characters. The leading character of the name must be alphabetic -not a number or special character. The name of a new index can not duplicate the name of an existing

    index for the same table and should not be the same as a SQL reserved word. The underscore character

    can be used to improve readability. List elements are seperated by commas.

    SQL DROP INDEX Syntax

    DROP INDEX .

    SQL ADD FOREIGN KEY Syntax

    ALTER TABLE

    ADD FOREIGN KEY

    ( , )

    REFERENCES

    ( ,

  • 8/9/2019 For a Further Description of SQL Functionality Please Click the Links at the Far Left on This Page.

    6/23

    )

    The number of characters that can make up SQL names for tables, columns and foreign keys varies byDBMS. In many cases the limit is 30 characters. The leading character of the name must be alphabetic -

    not a number or special character. The name of a new foreign key can not duplicate the name of an

    existing foreign key for the database and should not be the same as a SQL reserved word. To make theforeign key unique it is common practice to include the table and column name as part of the foreign

    key name. The underscore character can be used to improve readability. List elements are seperated by

    commas.

    SQL DROP FOREIGN KEY Syntax

    ALTER TABLE

    DROP FOREIGN KEY

    SQL CREATE VIEW Syntax

    CREATE VIEW (

    ,

    ) AS

    The number of characters that can make up SQL names for tables, columns and views varies by

    DBMS. In many cases the limit is 30 characters. The leading character of the name must be alphabetic -not a number or special character. The name of a new view can not duplicate the name of an existing

    view or table and should not be the same as a SQL reserved word. The underscore character can be

    used to improve readability. List elements are seperated by commas.

    SQL DROP VIEW Syntax

    DROP VIEW .


Recommended