zoukankan      html  css  js  c++  java
  • 基础SQL语句

    进入oracle 

    su - oracle 

    创建监听

    lsnrctl start                                                                             如果是第一次开启数据库,可能会出现数据库锁住的情况

    连接数据库                                                                               conn /as sysdba

    sqlplus / as sysdba                                                                  alter user scott identified by tiger account unlock;

    启动                                                                                       grant connect,resource to scott 

    startup                                                                                  conn scott/tiger

    连接用户

    conn scott/tiger    scott为用户  tiger为密码

    基础语句:

    创建用户         creat user scott indentified by oracle;

    删除用户     drop user scott cascade;

    选择        select * from emp;

    在select语句中可执行运算(+,-,*,/)优先级问题

    eg:

    select ename,empno,sal ,sal+10 from em

    定义别名:             select ename as name from emp;      或   select ename name from emp;如果别名中包含空格或特殊字符需用" "将其引起

    消除空行:                   select distinct deptno from emp;

    between and的使用    select sal from emp where sal between 1000 and 1500;

    in 的使用                 select sal from emp where sal in (1000,1100,1200);

    is null的使用            select sal from emp where comm is null;

    空值和任何值进行计算的结果依然为空值

    nvl函数  nvl(com,0)当com值为空值时用0代替

    avg函数可以自动忽略空值

                  

    like的使用:             select ename  from emp where ename like 's%';    %为0个或多个字符   _代表一个字符

    友好输出:

    SELECT ename  || ' is a ' ||job  AS "Employee Details"  FROM   emp;

     order by 子句:             默认为升序

    ASC: 升序, 缺省     

    DESC: 降序

  • 相关阅读:
    【并查集】hdu 1198 Farm Irrigation
    【并查集】hdu 1325 Is It A Tree?
    【并查集】hdu 1272 小希的迷宫
    【并查集】hdu 1856 More is better
    【并查集】hdu 3635 Dragon Balls
    【并查集】poj 1988 Cube Stacking
    【并查集】poj 2492 A Bug's Life(二集合问题)
    【并查集】poj 2236 Wireless Network
    【并查集】poj 1703 Find them, Catch them(二集合问题)
    【并查集】poj 1611 The Suspects
  • 原文地址:https://www.cnblogs.com/wangqianqiannb/p/4162254.html
Copyright © 2011-2022 走看看