SQL常用命令
来源:互联网 发布:旭辉写频软件 编辑:程序博客网 时间:2024/06/07 01:39
1:创建数据库
create datebase dbtest;
2:创建表 create table tabletest(
id char(10) ,
name varchar2(100) not null,
constraint pk_primary primary key(id,name)
);
3:查询语句
1)全部查询
select * from tabletest
2)跨表查询并排序
select a.*,b.* from tabletest aleft join tabletest1 b on a.id = b.idwhereb.name = '张三'order by a.id desc,b.id asc
3)查询相同及like 通配符
select distinct id,name from tabletest where id in ('1','2') or name like '%a%' or name like 'a_b_c' or name like '[!abc]';
4)平均数,总数,个数等查询
select avg(id) from tabletest;select sum(name) from tabletest;select count(*) from tabletest;select first(id) from tabletest;select last(name) from tabletest;select top 2 id from tabletest;select max(id),min(name) from tabletest;
4:插入语句
insert into tabletest (id,name) values('11','220');
5:更新语句
update tabletest set id = '22' ,name = '11' where id = '1';
0 0
- SQL常用命令
- SQL常用命令
- SQL常用命令
- sql常用命令
- SQL常用命令
- sql 常用命令
- SQL常用命令
- SQL常用命令
- sql常用命令
- SQL常用命令
- SQL常用命令
- SQL常用命令
- SQL常用命令
- SQL常用命令
- SQL常用命令
- SQL常用命令
- SQL常用命令
- SQL常用命令
- 1878: [SDOI2009]HH的项链
- 【Mybatis】深入浅出Mybatis(七)——别名使用
- Android使用Retrofit+OkHttp实现网络请求
- 如何使用Spring 配置各类(c3p0,dbcp,jndi)数据源以及jdbc
- leetcode_middle_83_200. Number of Islands
- SQL常用命令
- 【leetcode】264. Ugly Number II
- 数据库事务的四大特性以及事务的隔离级别
- 安装Groovy
- VS2010+SQlite+EF 踩过的坑
- 为activity设置左右的切换动画
- LeetCode题解(Week3):215. Kth Largest Element in an Array
- bzoj1018[SHOI2008]堵塞的交通traffic
- CodeForces