sql语句

快速建表:

CREATE TABLE IF NOT EXISTS `0708`(
   `pid` INT UNSIGNED AUTO_INCREMENT,
   `name` VARCHAR(100) NOT NULL,
   `birthday` DATE,
   PRIMARY KEY ( `pid` )
)ENGINE=InnoDB DEFAULT CHARSET=utf8;

修改表名称:

alter table test.0708 rename to test_table;

查看表结构:

mysql> desc test_table;
+----------+------------------+------+-----+---------+----------------+
| Field    | Type             | Null | Key | Default | Extra          |
+----------+------------------+------+-----+---------+----------------+
| pid      | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| name     | varchar(100)     | NO   |     | NULL    |                |
| birthday | date             | YES  |     | NULL    |                |
+----------+------------------+------+-----+---------+----------------+

插入数据:

insert into test_table (pid, name, birthday) values ('5', 'xiuer','1996-10-02'), ('12','lisi','2015-10-04'),('11','wangwu','2016-09-02'),('13','zhaoliu','2015-10-07');

查看数据:

mysql> select * from test_table;
+-----+----------+------------+
| pid | name     | birthday   |
+-----+----------+------------+
|   5 | xiuer    | 1996-10-02 |
|   8 | zhangsan | 2016-02-13 |
|  11 | wangwu   | 2016-09-02 |
|  12 | lisi     | 2015-10-04 |
|  13 | zhaoliu  | 2015-10-07 |
+-----+----------+------------+

非聚簇索引:
```shell
mysql> create index fpid on test_table(name);
Query OK, 0 rows affected (0.02 sec)
原文地址:https://www.cnblogs.com/sihye/p/13266611.html