forked from thatsabhishek/Coding_Ninjas_DBMS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquery2.sql
45 lines (38 loc) · 1.5 KB
/
query2.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
33
34
35
36
37
38
39
40
41
42
43
44
45
Problem Statement:
Create the customers table for this database.
The attributes and their respective datatypes are as follows:
Attributes | Data Type
customer_id | VARCHAR(20) (PRIMARY KEY)
customer_name | VARCHAR(225)
phone_no | INT
city | VARCHAR(200)
pin_code | INT
Information about the tables:
Given below is a database of a newly established e-commerce website.
The database contains multiple tables i.e. products, orders, and transactions.
The information about required tables is given below
Table transactions:
Attributes list:
Attributes | Data Type
transaction_id | VARCHAR(20) (PRIMARY KEY)
transaction_status | VARCHAR(25)
Note: Describe the complete table afterwards.
DESC table_name;
Solution:
CREATE TABLE customers (
customer_id VARCHAR(20) PRIMARY KEY,
customer_name VARCHAR(225),
phone_no INT,
city VARCHAR(200),
pin_code INT);
DESC customers;
Output:
+---------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| customer_id | varchar(20) | NO | PRI | NULL | |
| customer_name | varchar(225) | YES | | NULL | |
| phone_no | int | YES | | NULL | |
| city | varchar(200) | YES | | NULL | |
| pin_code | int | YES | | NULL | |
+---------------+--------------+------+-----+---------+-------+