-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlStatements.txt
More file actions
61 lines (38 loc) · 2.19 KB
/
sqlStatements.txt
File metadata and controls
61 lines (38 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
>>>>>>>>>>1. DML (Data Manipulation Language)<<<<<<<<<<<<<<<
DML statements are used to manipulate the data within the database.
These operations allow users to insert, update, delete, and retrieve data from the tables.
** INSERT: Adds new rows of data to a table.
INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);
** UPDATE: Modifies existing data within a table.
UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition;
** DELETE: Removes existing rows from a table.
DELETE FROM table_name WHERE condition;
** SELECT: Retrieves data from the database.
SELECT column1, column2, ... FROM table_name WHERE condition;
>>>>>>>>>>>2. DDL (Data Definition Language)<<<<<<<<<<<<<<<<<<
DDL statements are used to define and manage the database schema.
These commands create, alter, and delete database objects such as tables, indexes, and views.
** CREATE: Creates new database objects (e.g., tables, indexes).
CREATE TABLE table_name (
column1 datatype constraint,
column2 datatype constraint,
...
);
** ALTER: Modifies the structure of existing database objects.
ALTER TABLE table_name ADD column_name datatype constraint;
ALTER TABLE table_name DROP COLUMN column_name;
** DROP: Deletes existing database objects.
DROP TABLE table_name;
** TRUNCATE: Removes all rows from a table, resetting its storage.
TRUNCATE TABLE table_name;
>>>>>>>>>>>>>3. DCL (Data Control Language)<<<<<<<<<<<<<<<<<<<<<<<<<<
DCL statements control access to the data within the database.
These commands are used to grant and revoke privileges to users.
** GRANT: Provides specific privileges to users or roles.
GRANT SELECT, INSERT ON table_name TO user_name;
** REVOKE: Removes specific privileges from users or roles.
REVOKE SELECT, INSERT ON table_name FROM user_name;
>>>>>>>>>>>>>>>4. DQL (Data Query Language)<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
DQL statements are primarily used to query the database and retrieve data. The most common DQL command is:
** SELECT: Retrieves data from one or more tables.
SELECT column1, column2, ... FROM table_name WHERE condition;