SQL查询排序ORDER BY
order by
排序通过order by子句实现,order by在SELECT语句的最后。
语法:
order by field1 [ASC|DESC][,field2 [ASC|DESC],..,fieldn [ASC|DESC]]
ASC:升序
DESC:降序
默认为升序
空值作为无穷大来处理。
另外可以按照查询列表中序号进行排序。
系统在用户写出查询列表的同时就赋予每个列名一个序号,升序赋予,从1开始。
例:SELECT name,phone,adress from user
其中name序号为1,adress序号为2,其他依次类推。
示例:
SQL> select deptno,dname,loc from mydept order by 3;
按loc字段升序排列
相关文档:
如何远程判断Oracle数据库的安装平台
select * from v$version;
查看表空间的使用情况
select sum(bytes)/(1024*1024) as free_space,tablespace_name
from dba_free_space
group by tablespace_name;
SELECT A.TABLESPACE_NAME,A.BYTES TOTAL,B.BYTES ......
一、 镜像简介
1、 简介
数据库镜像是将数据库事务处理从一个SQL Server数据库移动到不同SQL Server环境中的另一个SQL Server数据库中。镜像不能直接访问;它只用在错误恢复的情况下才可以被访问。
要进行数据库镜像所需的最小需求包括了两个不同的SQL Server运行环境。主服务器被称为“主机”,第二个服务器被 ......
Using Oracle Trace Analyzer (trcanlzr.sql)
Dave Moore: Author of Oracle Utilities
Oracle has provided another utility initially designed for performance tuning Oracle Applications. Trace Analyzer is provided in the form of a PL/SQL package (TRCA$ ). The Trace Analyzer utility i ......
Questions
I have a simple app that
uses an SQL Express 2005 database. When the user closes the app, I want
to give the option to back up the database by making a copy in another
directory. However, when I try to do it, I get "The process cannot
access the file '...\Pricing.MDF' because i ......
select * from tableName where datediff(week,dateField,getdate())=0
这样查出来的结果是从星期天到星期六(老外默认星期天是一周的第一天).
如果想以星期一作为第一天的话,两个时间都需要减一,如下:
select * from tableName where datediff(week,dateField-1,getdate()-1)=0 ......