20170909 Learning SQL Notes

select * from employees;


select * from salaries where emp_no in
 (select emp_no from employees where gender='M'	)
 
Create Database	 YGGL

create table Employees
(
	EmployeeID char(6) not null,
	Name  char(10) not null,
	Education char(4) not null,
	Birthday datetime not null,
	Sex char(2) not null,
	WorkYear tinyint(1),
	Address varchar(20),
	PhoneNumber char(12),
	DepartmentID char(3) not null,
	PRIMARY KEY (EmployeeID)
)engine=InnoDB;

create table Employees1
(
	EmployeeID char(6) not null,
	Name  char(10) not null,
	Education char(4) not null,
	Birthday datetime not null,
	Sex char(2) not null,
	WorkYear tinyint(1),
	Address varchar(20),
	PhoneNumber char(12),
	DepartmentID char(3) not null,
	PRIMARY KEY (EmployeeID)
)engine=InnoDB;


Alter table employees1
	alter Sex set default 1,
	drop column Address;
	
	
	
	create table Deparments
	(
		departmentID char(3) not null,
		departmentName char(20) not null,
		note text(16),
		primary key (departmentID)
	)
	
	create table Salary
	(
		employeeID char(6) not null,
		Income float(8) not null,
		Outcome float(8) not null,
		primary key(employeeID)
	)
	
	insert into employees values ​​('000001', 'Wang Lin', 'Junior College', '1966-01-23', '1' ,'8', 'Zhongshan Road 32-1-508' ,'83355668' ,'2 ')
	
	insert into employees values
	('010008','Wu Ronghua','Undergraduate','1976-03-28','1','3','Beijing East Road 100-2','833211321','1'),
	 ('020010','Wang Xiangrong','Master','1982-12-09','1','2','Sipai Road 10-0-108','83792361','1')

	 
	 
select *  from employees
	 
	 
	 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326225599&siteId=291194637