数据库操作
#登录数据库:mysql -hlocalhost -uroot -p;
#修改密码:mysqladmin -uroot -pold password new;
进入数据库:use database;
显示数据库内容:describe database;
表格操作
创建表格:create table table1(
id int(10) not null auto_increment,
name varchar(15) not null,
primary key(id),
)
更改表格名称:alter table table1 rename table2;
增删查改
在表格中增加一个字段:alter table table1 add field1 int(5) not null;
在表格中删除一个字段:alter table table1 drop field1;
在表格中修改一个字段的名称:alter table table1 change field1 fiedld2 varchar(5);
给表格中的字段添加索引:alter table table1 add index(field1,field2);
给表格中的字段删除索引:alter table table1 drop index field1;
给表格中的字段修改类型: alter table table1 modify column field1 int(5);
连接表查询:select table1.name from table1 left join table2 on table1.firstId = table2.firstId
append()函数是添加的意思
zerofill,表示自动填0,和默认值为0差不多.
unsigned,表示该字段存放一个无符号值,只存正数,不存负数。
故UNSIGNED ZEROFILL是无符号补零的意思。