数据表查询操作
案例测试:employee,dept表结构以表的记录
创建数据库,连接数据库
创建表:
CREATE TABLE dept
(
d_no INT PRIMARY KEY AUTO_INCREMENT,
d_name VARCHAR(50),
d_location VARCHAR(100)
)ENGINE=InnoDB;
CREATE TABLE employee
(
e_no INT PRIMARY KEY,
e_name VARCHAR(10) NOT NULL,
e_gender CHAR(2) NOT NULL,
dept_no INT NOT NULL,
e_job VARCHAR(100) NOT NULL,
e_salary SMALLINT NOT NULL,
hireDate DATE,
CONSTRAINT dno_fk FOREIGN KEY (dept_no)REFERENCES dept(d_no)
)ENGINE=InnoDB;
INSERT INTO dept VALUES (10,'ACCOUTING','ShangHai'),(20,'RESEARCH','Beijig'),(30,'SALES','Shenzhen'),(40,'OPERATIONS','FuJian');
INSERT INTO employee VALUES(1001,'SMITH','m',20,'CLERK',800,'2005-11-12');
INSERT INTO employee VALUES(1002,'ALLEN','f',30,'SALESMAN',1600,'2003-05-12');
INSERT INTO employee VALUES(1