本文共 2315 字,大约阅读时间需要 7 分钟。
SELECT {[distinct]列名,列名,…}|* FROM 表名 [WHERE 条件] [GROUP BY 分组列名][HAVING 聚合函数] [ORDER BY 排序列名 ASC|DESC]
select * from l_suppliers where supplier_name like '%''%'
SELECT EMPNO AS "员工编号", ENAME AS "员工名称" FROM EMP;SELECT EMPNO 员工编号, ENAME 员工名称 FROM EMP;SELECT EMPNO "员工编号", ENAME "员工名称" FROM EMP;
--员工分布在哪些部门 ,列出部门IDSELECT DISTINCT DEPARTMENT_ID FROM EMPLOYEES;
DESC OWNER.TABLE_NAMESELECT COLUMN_NAME, DECODE(NULLABLE, 'Y', ' ', 'NOT NULL') NULLABLE, DECODE(DATA_TYPE, 'RAW', DATA_TYPE || '(' || DATA_LENGTH || ')', 'CHAR', DATA_TYPE || '(' || DATA_LENGTH || ')', 'VARCHAR', DATA_TYPE || '(' || DATA_LENGTH || ')', 'VARCHAR2', DATA_TYPE || '(' || DATA_LENGTH || ')', 'NUMBER', NVL2(DATA_PRECISION, DECODE(DATA_SCALE, 0, DATA_TYPE || '(' || DATA_PRECISION || ')', DATA_TYPE || '(' || DATA_PRECISION || ',' || DATA_SCALE || ')'), DATA_TYPE), DATA_TYPE) DATA_TYPE FROM DBA_TAB_COLUMNS WHERE OWNER = UPPER('&sch') AND TABLE_NAME = UPPER('&tab') ORDER BY COLUMN_ID
--*:表示查询所有列 select * from employees;--查询固定列 select DEPARTMENT_NAME, MANAGER_IDfrom departments;--*:在运算符里表示乘以 select FIRST_NAME 名字, SALARY * COMMISSION_PCT*12 年度奖金from employeeswhere salary > 10000;--||:拼接字符串 --'':表示单引号,在字符串里显示,用于区分'结束输出 select last_name || ' ''s salary is : ' || salary aaafrom employeeswhere salary > 10000;--多个单引号时使用q'[]',避免多次使用''select last_name || q'[ 's sa'la'ry' is : ]' || salary aaafrom employeeswhere salary > 10000;
转载地址:http://njrlo.baihongyu.com/