创建数据库
create database dbname;
创建数据表
create table tablename(name char(50) not null ,
id int unsigned not null auto_increment primary key,
);
插入数据
方法一:insert into tablename(column1,column2...) values (value1,value2...); //常用方法
方法二:inset into tablename values(value1,value2,value3...);//这种方法一定要值对应数据库的字段,一般不建议这种方法
方法三:inset into tablename set colum1='value1',colum2='value2',colum3='value3',....
从数据库中获取数据
select [options] items [INTO file_details]
from tables [where conditions] //条件
[group by group_type]
[having where_definition]
[order by order_type] //排序
[limit limit_criteria] //分页
[procedure proc_name(arguments)]
[lock_options];
栗子:查询cus表中name字段还有city字段的数据
select name, city from cus;
修改语句:
update [low_priority] [ignore] tablename set column1 =expression1,columen2=expression2,...
[where condition]
[order by order_criteria]
[limit number]
删除表中的记录:
delete [low_priority] [quick] [ignore] from table [where condition] [order by order_cols][limit number]
注意:delete from table;//所有表中的行讲被删除
删除表
drop table tablename;
删除整个数据库
drop database dataname;