-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay 1.txt
More file actions
61 lines (46 loc) · 1.13 KB
/
Day 1.txt
File metadata and controls
61 lines (46 loc) · 1.13 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
create database sql_workbench;
use sql_workbench;
#Numeric Functions
-- select abs(-89);
-- select mod(10.3 ,4) as rem;
-- select power(4,2);
-- select sqrt(8);
-- select greatest(8, 19, 90, 999);
-- select least(8, 19, 90, 999);
-- select truncate(33.889, 2);
-- created table
CREATE TABLE employees(
employee_id INT,
first_name VARCHAR(50),
last_name VARCHAR(50),
hourly_pay DECIMAL(5, 2),
hire_date DATE
);
select * from employees;
rename table employees to workers;
rename table workers to employees;
-- drop table employees;
-- command to drop a table
-- adding a column to our table
alter table employees
add phone_number varchar(15);
select * from employees;
-- renaming column
alter table employees
rename column phone_number to email;
select * from employees;
alter table employees
modify column email varchar(100);
-- to move column
alter table employees
modify email varchar(100)
after last_name;
select * from employees;
-- putting the col at the first place
alter table employees
modify email varchar(100)
first;
select * from employees;
-- dropping column email
alter table employees
drop column email;