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: 降序

  • 相关阅读:
    linux 进程等待 wait 、 waitpid
    数理逻辑量词的引入
    Android自己定义动态布局 — 多图片上传
    Dynamics CRM 2015/2016 Web API:Unbound Custom Action 和 Bound Custom Action
    iOS 9应用开发教程之显示编辑文本标签文本框
    iOS 9应用开发教程之ios9中实现按钮的响应
    iOS 9应用开发教程之使用代码添加按钮美化按钮
    iOS 9应用开发教程之ios9的视图
    iOS 9应用开发教程之定制应用程序图标以及真机测试
    iOS 9应用开发教程之编辑界面与编写代码
  • 原文地址:https://www.cnblogs.com/wangqianqiannb/p/4162254.html
Copyright © 2011-2022 走看看