SQL RDBMS

SQL RDBMS


SQL – sintaksisi

SQL-ga Syntax deb ataladigan yagona qoidalar va ko'rsatmalar to'plami amal qiladi. Ushbu dars sizga barcha asosiy SQL sintaksisini kiritish orqali SQL bilan tez boshlanish imkonini beradi.

Barcha SQL so'rovlari SELECT, INSERT, UPDATE, DELETE, ALTER, DROP, CREATE, USE, SHOW kabi barcha kalit so'zlardan boshlanadi va barcha so'zlar nuqta-vergul (;) bilan yakunlanadi.

Bu erda ta'kidlanish kerak bo'lgan eng muhim nuqta - bu SELECT degan ma'noni anglatadi va SQL iboralarida bir xil ma'noga ega SQL deganidir. Holbuki, MySQL jadval nomlarida farq qiladi. Shunday qilib, MySQL bilan ishlayotgan bo'lsangiz, ma'lumotlar bazasida mavjud bo'lgan jadval nomlarini berishingiz kerak.

SQLda turli xil sintaksis

Ushbu qo'llanmada berilgan barcha misollar MySQL-server bilan sinab ko'rilgan.

SQL SELECT bayonoti

Namuna:

        SELECT column1, column2....columnN
        FROM  table_name;
                

SQL DISTINCT Clause

Namuna:

             SELECT DISTINCT column1, column2....columnN
             FROM  table_name;
                

SQL WHERE Clause

Namuna:

        SELECT column1, column2....columnN
        FROM table_name
        WHERE CONDITION;
     

SQL AND/OR Clause

Namuna:

        SELECT column1, column2....columnN
        FROM table_name
        WHERE CONDITION-1 {AND|OR} CONDITION-2;
                

SQL IN Clause

Namuna:

        SELECT column1, column2....columnN
        FROM table_name
        WHERE column_name IN (val-1, val-2,...val-N);
                

SQL BETWEEN Clause

Namuna:

        SELECT column1, column2....columnN
        FROM table_name
        WHERE column_name BETWEEN val-1 AND val-2;

SQL LIKE Clause

Namuna:

        SELECT column1, column2....columnN
        FROM table_name
        WHERE column_name LIKE { PATTERN };

SQL ORDER BY Clause

Namuna:

        SELECT column1, column2....columnN
        FROM table_name
        WHERE CONDITION
        ORDER BY column_name {ASC|DESC}; 

SQL GROUP BY Clause

Namuna:

        SELECT SUM(column_name)
        FROM table_name
        WHERE CONDITION
        GROUP BY column_name;

SQL COUNT Clause

Namuna:

        SELECT COUNT(column_name)
        FROM table_name
        WHERE CONDITION; 

SQL HAVING Clause

Namuna:

        SELECT SUM(column_name)
        FROM table_name
        WHERE CONDITION
        GROUP BY column_name
        HAVING (arithematic function condition);

SQL CREATE TABLE Statement

Namuna:

        CREATE TABLE table_name(
        column1 datatype,
        column2 datatype,
        column3 datatype,
        .....
        columnN datatype,
        PRIMARY KEY( one or more columns )
        ); 

SQL DROP TABLE Statement

Namuna:

        DROP TABLE table_name

SQL CREATE INDEX Statement

Namuna:

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

SQL DROP INDEX Statement

Namuna:

        ALTER TABLE table_name
        DROP INDEX index_name;



                

SQL DESC Statement

Namuna:

            DESC table_name;

SQL TRUNCATE TABLE Statement

Namuna:

        TRUNCATE TABLE table_name;

SQL ALTER TABLE Statement

Namuna:

            ALTER TABLE table_name {ADD|DROP|MODIFY} column_name {data_ype};

SQL ALTER TABLE Statement (Rename{Nomini o`zgartirish})

Namuna:

         ALTER TABLE table_name RENAME TO new_table_name;
                

SQL INSERT INTO Statement

Namuna:

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

SQL UPDATE Statement

Namuna:

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

SQL DELETE Statement

Namuna:

            DELETE FROM table_name
            WHERE
            {CONDITION}; 

SQL CREATE DATABASE Statement

Namuna:

            CREATE DATABASE database_name;   

SQL DROP DATABASE Statement

Namuna:

            DROP DATABASE database_name;

SQL USE Statement

Namuna:

            USE database_name;
                

SQL COMMIT Statement

Namuna:

            COMMIT;
                

SQL ROLLBACK Statement

Namuna:


            ROLLBACK;

                

Innovative Lab web sahifasiga xush kelibsiz biz bilan birga IT sohasidagi o'z bilimlaringizni bosqichma-bosqich oshirib boring!


Telegram kanalimizdan kunlik darslarni o'rganing  

TOSHKENT SHAHRIDAGI INHA UNIVERSITETI - 2017