Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • SQL Tutorial -> Sql Syntax

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 440
    Comment on it

    <-- Chapter 1 Introduction to SQL

    Chapter 2

    SQL Syntax

    SQL Syntax : SQL syntax is basically followed by sql commands which modifies the database tables such as "users" , "students" etc. All the SQL statements always starts with the keywords SELECT, INSERT, UPDATE, DELETE, ALTER, DROP, CREATE, USE, SHOW . All these statements ends with semicolon i.e ";" . In SQL statements table name plays a big role , whether table exists in the database or not.


    Important point is to be noted that SQL is case insensitive, it means select and SELECT known as the same meaning and functioning. They both work as same.

    SQL contains many commands to modify database tables.

    • SELECT Statement

    SELECT column1, column2....columnN 
    FROM tablename;
    
    • DISTINCT Clause

    SELECT DISTINCT column_name
    FROM tablename;
    
    • WHERE Clause

    SELECT column1, column2....columnN
    FROM tablename
    WHERE CONDITION;
    
    • AND/OR Clause

    SELECT column1, column2....columnN
    FROM tablename
    WHERE CONDITION-1 {AND|OR} CONDITION-2;
    • IN Clause

    SELECT column1, column2....columnN
    FROM tablename
    WHERE columnname IN (value-1, value-2,...value-N);
    • BETWEEN Clause

    SELECT column1, column2....columnN
    FROM tablename
    WHERE columnname BETWEEN value-1 AND value-2;
    • LIKE Clause

    SELECT column1, column2....columnN
    FROM tablename
    WHERE columnname LIKE { PATTERN };
    • ORDER BY Clause

    SELECT column1, column2....columnN
    FROM tablename
    WHERE  CONDITION
    ORDER BY columnname {ASC|DESC};
    • GROUP BY Clause

    SELECT SUM(columnname)
    FROM tablename
    WHERE CONDITION
    GROUP BY columnname;
    • COUNT Clause

    SELECT COUNT(columnname)
    FROM tablename
    WHERE CONDITION;
    • HAVING Clause

    SELECT SUM(columnname)
    FROM   tablename
    WHERE  CONDITION
    GROUP BY columnname
    HAVING (arithmatic function condition);
    • CREATE TABLE Statement

    CREATE TABLE tablename(
    column1 datatype,
    column2 datatype,
    column3 datatype,
    .....
    columnN datatype,
    PRIMARY KEY( one or more columns )
    );
    • DROP TABLE Statement

    DROP TABLE table_name;
    • CREATE INDEX Statement

    CREATE UNIQUE INDEX index_name
    ON table_name ( column1, column2,...columnN);
    • DROP INDEX Statement

    ALTER TABLE table_name
    DROP INDEX index_name;
    • DESC Statement

    DESC table_name;
    • TRUNCATE TABLE Statement

    TRUNCATE TABLE table_name;
    • ALTER TABLE Statement

    ALTER TABLE table_name {ADD|DROP|MODIFY} column_name {data_ype};
    • ALTER TABLE Statement (Rename)

    ALTER TABLE table_name RENAME TO new_table_name;
    • INSERT INTO Statement

    INSERT INTO table_name( column1, column2....columnN)
    VALUES ( value1, value2....valueN);
    • UPDATE Statement

    UPDATE table_name
    SET column1 = value1, column2 = value2....columnN=valueN
    [ WHERE  CONDITION ];
    • DELETE Statement

    DELETE FROM table_name
    WHERE  {CONDITION};
    • CREATE DATABASE Statement

    CREATE DATABASE database_name;
    • DROP DATABASE Statement

    DROP DATABASE database_name;
    • USE Statement

    USE database_name;
    • COMMIT Statement

    COMMIT;
    • ROLLBACK Statement

    ROLLBACK;

    Chapter 3: SQL Select -->

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: