-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01_Database_Operations.sql
More file actions
69 lines (38 loc) · 1.32 KB
/
Copy path01_Database_Operations.sql
File metadata and controls
69 lines (38 loc) · 1.32 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
59
60
61
62
63
64
65
66
67
68
69
-- ===========================================
-- Database Operations
-- ===========================================
-- ===========================================
-- ALTER TABLE
-- ===========================================
-- Query 1 - Add a New Column
ALTER TABLE customers
ADD COLUMN phone VARCHAR(15);
-- Query 2 - Rename a Column
ALTER TABLE customers
RENAME COLUMN phone TO mobile_number;
-- Query 3 - Change Column Data Type
ALTER TABLE customers
ALTER COLUMN mobile_number TYPE VARCHAR(20);
-- Query 4 - Drop a Column
ALTER TABLE customers
DROP COLUMN mobile_number;
-- ===========================================
-- TRUNCATE TABLE
-- ===========================================
-- Query 5 - Remove All Data from Sales Table
TRUNCATE TABLE sales;
-- Query 6 - Remove All Data and Reset Identity
TRUNCATE TABLE sales
RESTART IDENTITY;
-- ===========================================
-- DROP TABLE
-- ===========================================
-- Query 7 - Drop Products Table
DROP TABLE products;
-- Query 8 - Drop Products Table If Exists
DROP TABLE IF EXISTS products;
-- ===========================================
-- DROP DATABASE
-- ===========================================
-- Query 9 - Drop Company Database
DROP DATABASE company_db;