DB(general syntaxes)

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/51

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 5:33 PM on 5/24/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

52 Terms

1
New cards

What are the 3 main SQL language categories?

DDL (structure), DML (data manipulation), DCL (access control)

2
New cards

What is DDL (LDD)?

Language used to create and modify database structure (tables, schema)

3
New cards

What is DML (LMD)?

Language used to insert, update, delete, and query data

4
New cards

What is DCL (LCA)?

Language used to manage user permissions and privileges

5
New cards

What does CREATE DATABASE do?

Creates a new database

6
New cards

SQL syntax to create a database

CREATE DATABASE nom_base;

7
New cards

Why use USE command in SQL?

To select the database to work on

8
New cards

SQL syntax to select a database

USE nom_base;

9
New cards

What does DROP DATABASE do?

Deletes a database and all its data permanently

10
New cards

SQL syntax to delete a database

DROP DATABASE nom_base;

11
New cards

What does SHOW DATABASES do?

Lists all available databases

12
New cards

What is a table in SQL?

A structure used to store data in rows and columns

13
New cards

SQL syntax to create a table

CREATE TABLE nom_table (colonne TYPE contraintes);

14
New cards

What is INT type?

Integer number

15
New cards

What is VARCHAR?

Short text (variable length string)

16
New cards

What is TEXT?

Long text

17
New cards

What is DATE?

Date in format YYYY-MM-DD

18
New cards

What is DATETIME?

Date and time (YYYY-MM-DD HH:MM:SS)

19
New cards

What is DECIMAL(p,s)?

Decimal number with precision and scale

20
New cards

What is BOOLEAN?

TRUE or FALSE values

21
New cards

What is FLOAT?

Floating-point number

22
New cards

What is a PRIMARY KEY?

Unique identifier for each row in a table

23
New cards

Two ways to define PRIMARY KEY

Inline in column OR at end of table definition

24
New cards

Why is PRIMARY KEY important?

Ensures uniqueness and prevents duplicate rows

25
New cards

What is a FOREIGN KEY?

A foreign key is a column in one table that points to the primary key of another table.(It creates a link (relationship) between two tables.)

26
New cards

Purpose of FOREIGN KEY

Maintains referential integrity between tables

27
New cards

SQL syntax for FOREIGN KEY

FOREIGN KEY (col) REFERENCES table(col)

28
New cards

What does NOT NULL do?

Ensures a column cannot have NULL values

29
New cards

SQL syntax for NOT NULL

colonne TYPE NOT NULL

30
New cards

What does UNIQUE constraint do?

Ensures all values in a column are different

31
New cards

Two ways to define UNIQUE

inline definition OR after table definition

32
New cards

What is CHECK constraint?

Enforces a condition on column values

33
New cards

SQL syntax for CHECK

CHECK (condition)

34
New cards

What is DEFAULT constraint?

Sets a default value if none is provided

35
New cards

SQL syntax for DEFAULT

colonne TYPE DEFAULT valeur

36
New cards

What does ALTER TABLE do?

Modifies an existing table

37
New cards

SQL syntax to add a column

ALTER TABLE nom_table ADD colonne TYPE;

38
New cards

SQL syntax to modify column type

ALTER TABLE nom_table MODIFY colonne TYPE;

39
New cards

SQL syntax to rename a column

ALTER TABLE nom_table RENAME COLUMN old TO new;

40
New cards

SQL syntax to add a constraint

ALTER TABLE nom_table ADD CONSTRAINT name TYPE (col);

41
New cards

SQL syntax to drop a column

ALTER TABLE nom_table DROP COLUMN colonne;

42
New cards

SQL syntax to drop a constraint

ALTER TABLE nom_table DROP CONSTRAINT name;

43
New cards

SQL syntax to delete a table

DROP TABLE nom_table;

44
New cards

What does SHOW TABLES do?

Lists all tables in the current database

45
New cards

What does DESCRIBE or DESC do?

Shows table structure (columns, types, constraints)

46
New cards

What is referential integrity?

Ensures consistency between related tables

47
New cards

What happens with ON DELETE CASCADE?

Deletes child rows automatically

48
New cards

What happens with ON UPDATE CASCADE

Updates child rows automatically

49
New cards

What happens with ON DELETE SET NULL

Sets foreign key to NULL when parent is deleted

50
New cards

What happens with ON UPDATE SET NULL

Sets foreign key to NULL when parent is updated

51
New cards

What does RESTRICT do?

Prevents deletion/update if referenced

52
New cards

What does NO ACTION do?

Like RESTRICT but checked at end of transaction