首页 > Scott用户的表结构

Scott用户的表结构

Oracle笔记(三) Scott用户的表结构

创建备份表

–create table emp2 as select * from emp;

更新

–select * from emp where ename='SCOTT';

–update emp set deptno=10 where ename='SCOTT';

–update emp set mgr=7833, hiredate=date'1985-01-05' where ename='SCOTT';

删除

–delete from emp where empno=7788;

插入

–Insert into EMP (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO) Values (7788, 'SCOTT', 'ANALYST', 7566, TO_DATE('04/19/1987 ', 'MM/DD/YYYY'), 3000, 20);

2014 V1.5

SELECT的基本构成

经典格式

–select job, count(distinct deptno) from emp where mgr is not null group by job order by count(distinct deptno) desc, job;

–select job, count(distinct deptno) from emp where mgr is not null group by job order by 2 desc, job;

–select job, count(distinct deptno) uniq_deptno from emp where mgr is not null group by job order by uniq_deptno des c, job;

–select deptno, to_char(hiredate,'yyyy'), count(*) from emp group by deptno, to_char(hiredate,'yyyy');

–select deptno, to_char(hiredate,'yyyy'), count(*) from emp group by deptno, 2;

–select deptno, to_char(hiredate,'yyyy') hireyear, count(*) from emp group by deptno, hireyear;

–select deptno, to_char(hiredate,'yyyy'), count(*) from emp group by to_char(hiredate,'yyyy'), deptno;

经典格式

–select * from emp;

–select * from emp where empno>8000;

–select empno, ename, sal, comm from emp where sal
–select deptno, count(*) from emp group by deptno;

–select deptno, sum(sal) total_sal from emp where job='MANAGER' group by deptno;

–select job, count(distinct deptno) from emp where mgr is not null group by job order by job;

转载于:https://www.cnblogs.com/lujun/p/3714199.html

更多相关:

  • --constraint --not null 非空约束 --unique 唯一键 --非空&唯一 --自定义检查约束 --创建约束时,为约束起名 --在添加完列后,还可以添加约束 --除了not null不可以   --主键约束 --为了保证该列的数据能够证明行记录在表中是唯一的 --主键约束从形式看,类同于(非空和唯一)约束 --...

  • 数据分析过程中,我们经常可以看到提数的SQL语句,了解SQL常用的基础查询语句,是检验提数逻辑是否正确的途径之一,并且也能更方便使用SMART BI数据分析工具。今天就让小编带大家走进SQL基础查询的世界吧~1、查询单个字段:语法:SELECT 字段名 FROM 表名举例:SELECT first_name FROM employ...

  •   SELECT * FROM tableSELECT * FROM table WHERE name = '强哥'SELECT * FROM table ORDER BY updateTime DESC...

  • 使用 OpenRowSet 和 OpenDataSource 访问 Excel 97-2007 测试文件:D:97-2003.xls和D:2007.xlsx,两个文件的内容是一模一样的。 测试环境:SQL Server 2000 / 2005。 -------------------------------------------...

  • exec sp_configure 'show advanced options',1 reconfigure exec sp_configure 'Ad Hoc Distributed Queries',1 reconfigure SELECT * INTO tmp_asset FROM OPENROWSET('Microsof...

  • select b.*,(select count(a.id) from td_product a where a.protypeid=b.id) num from td_protype b 转载于:https://www.cnblogs.com/shanlin/archive/2011/09/27/2192725.html...