Home > Database > Mysql Tutorial > MySQL的DML_MySQL

MySQL的DML_MySQL

WBOY
Release: 2016-06-01 13:10:36
Original
1541 people have browsed it

1、创建表

CREATE TABLE `photo_tsk` (`id`  char(36) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '主键' ,`creator_id`  int(11) NULL DEFAULT NULL COMMENT '创建者id' ,`create_time`  datetime NULL DEFAULT NULL COMMENT '创建时间' ,`last_update_time`  datetime NULL DEFAULT NULL COMMENT '最后更新时间' ,`assigner_id`  int(11) NULL DEFAULT NULL COMMENT '分配者id' ,`assign_time`  datetime NULL DEFAULT NULL COMMENT '分配时间' ,`photo_grapher_id`  int(11) NULL DEFAULT NULL COMMENT '摄影师' ,`finish_time`  datetime NULL DEFAULT NULL COMMENT '拍摄完成时间' ,`photo_place`  int(11) NULL DEFAULT NULL COMMENT '拍摄地点' ,`desc_url`  varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '详情链接' ,`task_desc`  varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务描述' ,`status`  tinyint(4) NULL DEFAULT NULL ,PRIMARY KEY (`id`))ENGINE=InnoDBDEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ciROW_FORMAT=COMPACT;
Copy after login

 

2、更改类型

    alter table photo_tsk modify task_desc mediumtext 只能更改类型

    alter table photo_tsk change task_desc tdesc mediumtext 可以同时修改字段名和类型

 

3、增加字段

    alter table product add vend_phone char(20)

 

4、删除字段

     alter table product drop column vend_phone

 

5、重命名表

    rename table product to product_info

 

6、增加索引

    alter table photo_task add index idx_creator_id(creator_id)

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template