加入收藏 | 设为首页 | 会员中心 | 我要投稿 晋中站长网 (https://www.0354zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

mysql数据库创建表

发布时间:2022-10-30 15:02:09 所属栏目:MySql教程 来源:网络
导读: 1.创建一个名称为employee的mysql默认类型MyISAM表
create table employee (id smallint(5) not null,depno int(5) not null,name varchar(20) not null,cardnumber int(15) not null,prim

1.创建一个名称为employee的mysql默认类型MyISAM表

create table employee (id smallint(5) not null,depno int(5) not null,name varchar(20) not null,cardnumber int(15) not null,primary key (id,depno));

插入一条记录

insert into employee values(1,805,'jim'MySQL 创建数据表,2010090101);

2.创建和employee的表结构一样的一个表employee1

create table employee1 like employee

3.创建带有employee表数据的表employee2

create table employee2 select * from employee

4.在mysql数据库中建立一个employee表

create table mysql.employee like employee;

5.显示创建表employee的表结构

mysql> desc mysql.employee;

+------------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+------------+-------------+------+-----+---------+-------+

| id | smallint(5) | NO | PRI | NULL | |

| depno | int(5) | NO | PRI | NULL | |

| name | varchar(20) | NO | | NULL | |

| cardnumber | int(15) | NO | | NULL | |

+------------+-------------+------+-----+---------+-------+

4 rows in set (0.01 sec)

mysql> drop table mysql.employee;

Query OK, 0 rows affected (0.00 sec)

6.在mysql数据库中创建一个带有数据的employee表

mysql> create table mysql.employee select * from employee;

Query OK, 1 row affected (0.02 sec)

Records: 1 Duplicates: 0 Warnings: 0

mysql> select * from mysql.employee;

+----+-------+--------+------------+

| id | depno | name | cardnumber |

+----+-------+--------+------------+

| 1 | 805 | liming | 2010090101 |

+----+-------+--------+------------+

1 row in set (0.00 sec)

(编辑:晋中站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!