Mysql操作语句

创建数据库

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;


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值