-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03_Creating_tables.sql
More file actions
60 lines (41 loc) · 953 Bytes
/
03_Creating_tables.sql
File metadata and controls
60 lines (41 loc) · 953 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
-- Using the college database
USE college;
-- Creating the students table
CREATE TABLE students (
student_id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50) NOT NULL,
email VARCHAR(50) UNIQUE,
age INT,
city VARCHAR(50),
enrollment_date DATETIME DEFAULT CURRENT_TIMESTAMP
);
-- Describing the structure of the students table
DESC students;
CREATE TABLE sales(
order_id INT PRIMARY KEY,
product_name VARCHAR(100),
quantity INT,
price DECIMAL(10, 2)
);
DESC sales;
SHOW TABLES;
-- Creating employees table
CREATE TABLE employees (
emp_id INT PRIMARY KEY,
emp_name VARCHAR(50),
dept_id INT
);
-- Creating departments table
CREATE TABLE department (
dept_id INT PRIMARY KEY,
dept_name VARCHAR(50)
);
CREATE TABLE final_students (
stu_id INT PRIMARY KEY,
name VARCHAR(50),
branch VARCHAR(50)
);
CREATE TABLE alumini (
name VARCHAR(50),
company VARCHAR(50)
);