常使用的sql语句

编程入门 行业动态 更新时间:2024-10-14 00:24:40

常使用的sql<a href=https://www.elefans.com/category/jswz/34/1770772.html style=语句"/>

常使用的sql语句

drop database * ;

开个玩笑!!哈啊哈

创建表

create table t1(id int not null primary key, name char(20) not null );语法 create table 表名称( 字段名 字段名类型 字段描述符,字段名 字段类型 字段描述符);

删除表

drop table test;语法:drop table 表名称;

修改表添加字段

alter table t1 add(score int not null)
语法:alter table 表明称 add(字段名 类型 描述符);

移除字段

alter table t1 drop column score;语法:alter table 表名 drop colunm 字段名,drop colunm 字段名;

变更字段

alter table t1 change name score int not null;语法:alter table 表名 change 旧字段名 新字段名 新字段描述符

插入

insert into winton values(001,'zww'),(002,'rs');语法:insert into 表名 values(字段1值,字段2值,……),(字段1值,字段2值,……);

查询

select * from t1 where socre>90;语法:select 字段1,字段2 from 表名 where 条件;

嵌套查询

select name from winton where id=(select id from t1 where score=90);语法:select 字段一,字段二…… from 表名 where 条件(查询);

删除

delete from winton where id=4;语法:delete from 表名 where 条件;

更新

update t1 set score=69 where id=2;语法:update 表名 set 更改的字段名=值 where 条件;

更多推荐

常使用的sql语句

本文发布于:2024-02-14 03:27:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1761608.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语句   sql

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!