登录mysql服务器 mystql -u root [-h hostname or ipaddr]-p
显示已有数据库:show databases;
选择数据库:use name_of_database;
创建数据库:create name_of_database;
显示当前数据库所包含的表:show tables;
创建表:create name_of_table
(
name_of_line data_class, -data_class can be int varchar(255),etc
name_of_line data_class,
,
,
)
;
显示表的内容:
select * from name_of_table;
显示表中某列的内容:
select name_of_line [,name_of_line] from name_of_table;
不重复的显示表中内容:
select distinct * from name_of_table;
排序显示表中内容:
select * from name_of_table order by name_of_line [desc];
选择给定约束的内容:
select * from name_of_table where name_of_line < some_value;
向表中插入值
insert into name_of_table value(value_of_line1,value_of_line2,,,);
更新表中的值
update name_of_table set name_of_line=value_of_line where name_of_otherline=value_of_otherline;
删除表中某条记录
delete from name_of_table where name_of_line=value_of_line;