基本语句

---------------------------------------数据库---------------------------------------
创建表
create table TABLE_NAME(
 'id' int(10) NOT NULL,
 'name' varchar(30) default NULL,
 'address' varchar(100) default NULL,
 PRIMARY KEY ('id')
)
修改表名
rename table TABLE_NAME_OLD to TABLE_NAME_NEW;
创建视图
create view VIEW_NAME as select * from TABLE_NAME;
select * from VIEW_NAME;
创建索引
create index INDEX_NAME on TABLE_NAME (COLUMN_NAME);
倒序查询
select * from TABLE_NAME order by column desc;
查询前5
select * from TABLE_NAME limit 5;
查询5到10行
select * from TABLE_NAME limit 4,6;
删除数据不删除表结构
delete from TABLE_NAME;
删除表数据和结构
drop table TABLE_NAME;
更新表数据
update TABLE_NAME set column= where column=;
update TABLE_NAME set column= where column is null;
表中插入列
alter table TABLE_NAME add (column datatype);
表中更新列
alter table TABLE_NAME change column_old column_new datatype;
表中删除列
alter table TABLE_NAME drop column;
插入表
insert into TABLE_NAME (column1,column2,column3) values ("","","");
多表查询:单个字段相同
select n.natmode,s.sipstackip from sipstackaddrconfig s,natconfig n where s.id=n.id
多表查询:多字段相同
select n.natmode,s.sipstackip from sipstackaddrconfig s join natconfig n using (id)
select n.natmode,s.sipstackip from sipstackaddrconfig s,natconfig n group by s.id

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值