当前位置:Gxlcms > 数据库问题 > MySQL_表操作语句

MySQL_表操作语句

时间:2021-07-01 10:21:17 帮助过:5人阅读

 

1、创建表(指定字符编码:utf8)

create table dbadmin ( id integer auto_increment primary key, username varchar(50) not null, password varchar(50) not null ) engine=InnoDB default charset=utf8;   1.1、 上面的命令 没成功,有报错(ERROR 1064 (42000))...   改成下面这样的方式(先 建一个没有自增的表,再 将主键设置成自增的): create table dbadmin ( id integer primary key, username varchar(50) not null, password varchar(50) not null ) engine=InnoDB default charset=utf8;   mysql> alter table dbadmin modify ID integer auto_increment;   2、 desc 表名(小写);    // mysql 查看表结构的命令 show tables;  //ZC: 显示所有表   3、 添加字段:

alter table table1 add transactor varchar(10) not null;    // 实际使用过,没有报错

alter table table1 add id int unsigned not null auto_increment primary key;  // 未实际使用过,不知是否会有报错

 

4、

 

   

 

MySQL_表操作语句

标签:

人气教程排行