Èíñòðóêöèÿ SQL SELECT

1

2

SELECTñòîëáåö1,ñòîëáåö2….ñòîëáåöN

FROMèìÿ_òàáëèöû;

Óñëîâèå SQL DISTINCT

1

2

SELECTDISTINCTñòîëáåö1,ñòîëáåö2….ñòîëáåöN

FROMèìÿ_òàáëèöû;

Óñëîâèå SQL WHERE

1

2

three

SELECTñòîëáåö1,ñòîëáåö2….ñòîëáåöN

FROMèìÿ_òàáëèöû

WHEREÓÑËÎÂÈÅ;

Óñëîâèå SQL AND/OR

1

2

three

SELECTñòîëáåö1,ñòîëáåö2….ñòîëáåöN

FROMèìÿ_òàáëèöû

WHEREÓÑËÎÂÈÅ-1ORÓÑËÎÂÈÅ-2;

Óñëîâèå SQL IN

1

2

three

SELECTñòîëáåö1,ñòîëáåö2….ñòîëáåöN

FROMèìÿ_òàáëèöû

WHEREèìÿ_ñòîëáöàIN(çíà÷åíèå-1,çíà÷åíèå-2,…çíà÷åíèå-N);

Óñëîâèå SQL BETWEEN

1

2

three

SELECTñòîëáåö1,ñòîëáåö2….ñòîëáåöN

FROMèìÿ_òàáëèöû

WHEREèìÿ_ñòîëáöàBETWEENçíà÷åíèå-1ANDçíà÷åíèå-2;

Óñëîâèå SQL LIKE

1

2

three

SELECTñòîëáåö1,ñòîëáåö2….ñòîëáåöN

FROMèìÿ_òàáëèöû

WHEREèìÿ_ñòîëáöàLIKEØÀÁËÎÍ;

Óñëîâèå SQL ORDER BY

1

2

three

four

SELECTñòîëáåö1,ñòîëáåö2….ñòîëáåöN

FROMèìÿ_òàáëèöû

WHEREÓÑËÎÂÈÅ

ORDERBYèìÿ_ñòîëáöàDESC;

Óñëîâèå SQL GROUP BY

1

2

three

four

SELECTSUM(èìÿ_ñòîëáöà)

FROMèìÿ_òàáëèöû

WHEREÓÑËÎÂÈÅ

GROUPBYèìÿ_ñòîëáöà;

Óñëîâèå SQL COUNT

1

2

three

SELECTCOUNT(èìÿ_ñòîëáöà)

FROMèìÿ_òàáëèöû

WHEREÓÑËÎÂÈÅ;

Óñëîâèå SQL HAVING

1

2

three

four

5

SELECTSUM(èìÿ_ñòîëáöà)

FROMèìÿ_òàáëèöû

WHEREÓÑËÎÂÈÅ

GROUPBYèìÿ_ñòîëáöà

HAVING(àðèôìåòè÷åñêàÿôóíêöèÿÓÑËÎÂÈÅ);

Èíñòðóêöèÿ SQL CREATE TABLE

1

2

three

four

5

6

7

eight

CREATETABLEèìÿ_òàáëèöû(

ñòîëáåö1òèïäàííûõ,

ñòîëáåö2òèïäàííûõ,

ñòîëáåö3òèïäàííûõ,

…..

ñòîëáåöNòèïäàííûõ,

PRIMARYKEY(îäèíèëèáîëååñòîëáöîâ)

);

Èíñòðóêöèÿ SQL DROP TABLE

1

2

three

four

DROPTABLEèìÿ_òàáëèöû;

ÈíñòðóêöèÿSQLCREATEINDEX

CREATEUNIQUEINDEXèìÿ_èíäåêñà

ONèìÿ_òàáëèöû(ñòîëáåö1,ñòîëáåö2,…ñòîëáåöN);

Èíñòðóêöèÿ SQL DROP INDEX

1

2

ALTERTABLEèìÿ_òàáëèöû

DROPINDEXèìÿ_èíäåêñà;

Èíñòðóêöèÿ SQL DESC

1

DESCèìÿ_òàáëèöû;

Èíñòðóêöèÿ SQL TRUNCATE TABLE

1

TRUNCATETABLEèìÿ_òàáëèöû;

Èíñòðóêöèÿ SQL ALTER TABLE

1

ALTERTABLEèìÿ_òàáëèöûDROPèìÿ_ñòîëáöà;

Èíñòðóêöèÿ SQL ALTER TABLE

1

ALTERTABLEèìÿ_òàáëèöûRENAMETOíîâîå_èìÿ_òàáëèöû;

Èíñòðóêöèÿ SQL INSERT INTO

1

2

INSERTINTOèìÿ_òàáëèöû(ñòîëáåö1,ñòîëáåö2….ñòîëáåöN)

ÇÍÀ×ÅÍÈÅS(çíà÷åíèå1,çíà÷åíèå2….çíà÷åíèåN);

Èíñòðóêöèÿ SQL UPDATE

1

2

three

UPDATEèìÿ_òàáëèöû

SETñòîëáåö1=çíà÷åíèå1,ñòîëáåö2=çíà÷åíèå2….ñòîëáåöN=çíà÷åíèåN

[WHEREÓÑËÎÂÈÅ];

Èíñòðóêöèÿ SQL DELETE

1

2

DELETEFROMèìÿ_òàáëèöû

WHERE;

Èíñòðóêöèÿ SQL CREATE DATABASE

1

CREATEDATABASEèìÿ_áàçû_äàííûõ;

Èíñòðóêöèÿ SQL DROP DATABASE

1

DROPDATABASEèìÿ_áàçû_äàííûõ;

Èíñòðóêöèÿ SQL USE

1

USEèìÿ_áàçû_äàííûõ;

Èíñòðóêöèÿ SQL COMMIT

1

COMMIT;

Èíñòðóêöèÿ SQL ROLLBACK

1

ROLLBACK;

Published by
Essays
View all posts