客戶端登錄服務器方式 mysql -u用戶名 -p密碼
建立數據庫:create database 數據庫名;
使用數據庫:use 數據庫名;
建表 :create table stu(
id int,
name varchar(10)
)engine myisam charset utf8;
清空表:truncate stu;
truncate相當於刪表再重建一張相同結構的表。
而delete相當於用橡皮擦把表的數據庫擦掉。
如果決定全清空的話truncate更快。
改表名:rename table stu to newstu;
查看表:select * from stu;
刪除表:drop table stu;
建表:
mysql> create table class(
-> id int primary key auto_increment,
-> sname varchar(10) not null default '',
-> gender char(1) not null default '',
-> company varchar(20) not null default '',
-> salary decimal(6,2) not null default 0.00,
-> fanbu smallint not null default 0
-> )engine myisam charset utf8;
