create database haha;
创建完后在/mysql/data查看有一个库目录
创建表: MySQL [hanhui]> create table t1;
ERROR 1113 (42000): A table must have at least 1 column-----------------à至少要有一个字段,否则创建不了
create table chengji(name char(10));
增加字段:
alter table t1 add name char(10); 默认字段时在最后的 show create table t1;
alter table t1 add sex char(10) after id; after---à在指定的字段之后添加
alter table t1 add addr char(10) first ; 将字段放到某字段最前面
增加记录:
insert into t1 set id=1,name='xiaoming'; #添加记录
insert into t1 values(ganzhou,2,'male','zhao',88); #一一对应关系进行添加记录
insert into t2 (id,name,linux) values(3,'qian',90);添加多条记录
insert into t2 (id,name,linux) values(4,'sun',93),(5,'li',76); #添加多条记录
插入数据:
insert into t1 set id=1,name='xiaoming'; 可以插入空数据,引号里面为空则数据为空
字符串要用引号引起来
如果字段里面的值为空又需要插入数据记录则要用update命令