-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDDL.sql
More file actions
39 lines (29 loc) · 801 Bytes
/
DDL.sql
File metadata and controls
39 lines (29 loc) · 801 Bytes
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
CREATE DATABASE IF NOT EXISTS org1;
USE org1;
DROP TABLE IF EXISTS account;
CREATE TABLE account (
id INT PRIMARY KEY,
name VARCHAR(25) UNIQUE,
balance INT NOT NULL DEFAULT 0
);
INSERT INTO account VALUES (1, 'Kinjal', 10000);
INSERT INTO account (id, name) VALUES (2, 'Arushi');
SELECT * FROM account;
-- Add new column
ALTER TABLE account
ADD COLUMN intrest FLOAT NOT NULL DEFAULT 0;
-- verify
DESCRIBE account;
SELECT * FROM account;
-- Modify
ALTER TABLE account
Modify intrest double not null DEFAULT 0;
DESCRIBE account;
-- change column - rename the column
ALTER TABLE account
change column intrest saving_interest FLOAT not null DEFAULT 0;
-- drop column
ALTER TABLE account drop COLUMN saving_interest;
--Rename the table
ALTER TABLE account
rename to account_details;