生僻sql
2016-05-12 00:00
274 查看
with 子句
提供定义临时关系的方法,这个定义只对包含with子句的查询有效。with子句是在SQL:1999中引入的,目前许多(但并非所有)数据库系统都提供支持
如上,建立了一个student_temp 的临时表,后者再根据student_temp来查询
case 结构
case语句可以用在任务应该出现值的地方
如上,在查询student表时,如果address为null.那么就用 '未知' 代替。
create table 扩展
当需要创建表参考现有的表,或将查询出来的数据保存到新表中
创建一张表参考现有的表
将查询出来的数据保存到新表中
上面的语法在不同的数据库系统中的实现也不一样,要参考相应的手册。
提供定义临时关系的方法,这个定义只对包含with子句的查询有效。with子句是在SQL:1999中引入的,目前许多(但并非所有)数据库系统都提供支持
[code=plain]with student_temp(id,name,age) as( select id,name,age from student where age > 20 ) select * from student_temp;
如上,建立了一个student_temp 的临时表,后者再根据student_temp来查询
case 结构
case语句可以用在任务应该出现值的地方
[code=plain]select id , case when address is null then '未知' else address end from student;
如上,在查询student表时,如果address为null.那么就用 '未知' 代替。
create table 扩展
当需要创建表参考现有的表,或将查询出来的数据保存到新表中
创建一张表参考现有的表
[code=plain]create table tmep_usr like s_user;
将查询出来的数据保存到新表中
[code=plain]create table temp_user as ( select * from s_user where dept = 1 )with data;
上面的语法在不同的数据库系统中的实现也不一样,要参考相应的手册。
相关文章推荐
- sql 视图
- 用SparkPost发送邮件
- oracle时间戳-日期转换
- 360开源的类Redis存储系统:Pika
- 数据库连接池
- MySQL模糊查询出现的问题与解决办法
- SQLException: Could not open JDBC Connection for
- NoSQL
- Oracle Logminer 与 rman 官方文档英文
- MySQL主库切换
- windows配置mysql5.6免安装版
- PostgreSQL 学习一 安装和入门
- Oracle BRM处理逻辑
- XTRABACKUP原理及使用INNOBACKUPEX进行MYSQL数据库备份恢复
- 基础算法7:从数据库某个字段中取出现次数最多的几条数据形成“热门xxx”
- MySQL错误日志总结
- 2016年5月11日摘自知乎的一些Redis大概了解
- vsftpd的基于pam_mysql的虚拟用户机制实现数据传输
- vsftpd的基于pam_mysql的虚拟用户机制实现数据传输
- Redis之2-双端链表(adlist.c,adlist.h)