forked from thatsabhishek/Coding_Ninjas_DBMS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsqlquery7.sql
32 lines (25 loc) · 1.03 KB
/
sqlquery7.sql
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
Problem Statement :
Given a table named Bank, write a query to change the existing column person_id to Pid VARCHAR(50).
table Bank
Attribute | Datatype
person_id | INT (Primary Key)
full_name | VARCHAR(30)
acc_no | INT
last_trans | VARCHAR (200)
phone_no | VARCHAR (200)
Syntax to describe the above table.
DESC <TABLE_NAME>;
Note: Write keywords of syntax in uppercase alphabets.
Solution :
ALTER TABLE Bank CHANGE COLUMN person_id Pid VARCHAR(50);
DESC Bank;
Output:
+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| Pid | varchar(50) | YES | | NULL | |
| full_name | varchar(30) | YES | | NULL | |
| acc_no | int | YES | | NULL | |
| last_trans | varchar(200) | YES | | NULL | |
| phone_no | varchar(200) | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+