mysql create创建表、insert into插入数据、select查询数据实例

时间:2016-09-02
本文章向大家介绍mysql如何使用sql语句创建表,然后使用insert into语句向表中插入数据以及select查询数据的实例,需要的朋友可以参考一下本文章的mysql源码。

mysql创建表的sql代码如下:

CREATE TABLE Employee(
     id            int,
     first_name    VARCHAR(15),
     last_name     VARCHAR(15),
     start_date    DATE,
     end_date      DATE,
     salary        FLOAT(8,2),
     city          VARCHAR(10),
     description   VARCHAR(15)
);

或者是

CREATE TABLE IF NOT EXISTS Employee(
     id            int,
     first_name    VARCHAR(15),
     last_name     VARCHAR(15),
     start_date    DATE,
     end_date      DATE,
     salary        FLOAT(8,2),
     city          VARCHAR(10),
     description   VARCHAR(15)
);

 

mysql insert into插入数据代码如下:

insert into Employee(id,first_name,last_name,start_date,end_Date,salary,City,Description) values (8,'James','Cat','19960917','20020415',1232.78,'Vancouver','Tester');
/*  http://www.manongjc.com/article/1437.html */

或批量插入:

insert into Employee(id,first_name,last_name,start_date,end_Date,salary,City,Description) values (8,'James','Cat','19960917','20020415',1232.78,'Vancouver','Tester'),(7,'David','Larry', '19901231','19980212',7897.78,'New York', 'Manager');

 

select查询表数据:

SELECT * FROM Employee WHERE (id,first_name) = (1,'Jason');

上一页 下一页

原文地址:http://www.manongjc.com/article/1437.html