-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathls_2_summery.sql
More file actions
68 lines (53 loc) · 2.46 KB
/
ls_2_summery.sql
File metadata and controls
68 lines (53 loc) · 2.46 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
62
63
64
65
66
67
68
create database summary_2;
use summary_2;
create table staff (
id int primary key auto_increment,
firstname varchar(60) not null,
lastname varchar(100) not null,
position varchar(100),
age int check(age between 0 and 110),
has_child char(1) check(has_child in ('Y', 'N')),
username varchar(100) unique not null
);
-- INSERT INTO staff (firstname, lastname, position, age, has_child, username)
-- VALUES ("John", "Johnson", "Developer", 45, "Y", "johnny"),
-- ("Sarah", "Connor", "Fighter", 15, "N", "sarah911");
-- INSERT INTO staff (firstname, lastname, position, age, has_child, username)
-- VALUES ("Arnold", "Schwarzneger", "Terminator", 105, "N", "t800"),
-- ("Amerigo", "Vespucci", "Researcher", 35, "Y", "liberty");
INSERT INTO staff (firstname, lastname, position, age, has_child, username)
VALUES ('Ally' , 'Austin' , 'Junior UI Designer' , 28 , 'N' , 'ally1' );
INSERT INTO staff (firstname, lastname, position, age, has_child, username)
VALUES ('Daniel', 'Faviet', 'Senior UX Designer', 43, 'Y', 'favietD');
INSERT INTO staff (firstname, lastname, position, age, has_child, username)
VALUES ('Lily', 'Chen', 'Senior Teacher', 25, 'Y', 'lilychen');
select * from staff;
-- Доп. задания.
-- Найти ошибку в коде:
-- insert into staff (firstname, lastname, age, has_child, username)
-- values ('Dave', 'Faviet', 23, 'YY', 'favietDv'); ===> Y
-- Создать и активировать базу данных tasks.
CREATE DATABASE tasks;
use tasks;
CREATE TABLE employees(
employee_id INT PRIMARY KEY AUTO_INCREMENT,
first_name VARCHAR(128),
last_name VARCHAR(128),
job VARCHAR(50) NOT NULL,
age INT CHECK(age > 18),
has_car CHAR(1) CHECK( has_car IN('Y', 'N')) DEFAULT 'N',
user_name VARCHAR(128) UNIQUE NOT NULL
);
INSERT INTO employees (first_name, last_name, job, age, has_car, user_name)
VALUES ("John", "Johnson", "Mechanic", 43, 'Y', "Iron man");
INSERT INTO employees (first_name, last_name, job, age, user_name)
VALUES ("Sarah", "Willson", "Teacher", 22, "LadyKnoleg");
INSERT INTO employees (first_name, last_name, job, age, has_car, user_name)
VALUES ("Will", "Smith", "Singer", 37, 'Y', "SadMan");
INSERT INTO employees (first_name, last_name, job, age, user_name)
VALUES ("Klaudia", "Cherepicca", "Actress", 88, "SaintOldy");
INSERT INTO employees (first_name, last_name, job, age, has_car, user_name)
VALUES ("Barak", "Obama", "President", 55, 'Y', "TheFirstMan");
SELECT * FROM employees;
DROP TABLE employees;
DROP DATABASE tasks;