数据库知识点

  1. 存放在数据库里面的基础的数据类型:
    char varchar2 number date

  2. create table 表名
    (
    列名 数据类型 [not null/primary key],
    ... ....,
    列名 数据类型
    )
    注意:最后一列定义时,不要加逗号;表名和列名只能由字母,数字,下划线组成,首字符必须是字母.而且要做到见名知义。

  3. insert into 表名(列名,...,列名) values(值,...,值);

    注意:值的数量,类型,顺序要和表名后面括号里的列名的数量,类型,顺序要一一对应
    如果这个列数据类型是number,值就直接写值
    如果这个列数据类型是char,varchar2,值就要用单引号引起来
    如果这个列数据类型是date,写值时就用to_date转化

  4. select */列名 from 表名 where 条件 order by 列号[asc/desc]

  5. update 表名 set 列名=值, ...,列名=值 where 条件

6 delete from 表名 where 条件

  1. 查询消除某个列重复数据用distinct
    用法: select distinct 列名 from 表名

  2. 空值操作
    为空用法: where 列名 is null
    不为空用法: where 列名 is not null

  3. in
    用法: where 列名 in(值,...,值)

  4. 模糊查找 like [% _]
    用法: where 列名 like 表达式

  5. 子查询[选学]

  6. 伪列[rowid,rownum] 选学

  7. 函数
    to_char to_date replace substr

    聚合函数
    avg sum count

    用法:
    select 分组列名, avg/sum/count(列名) from 表名 group by 列名 having 条件

  8. 索引
    索引是什么?
    怎么创建索引
    create [unique] index 索引名 on 表名(列名);
    drop index 索引名;

  9. 备份和恢复
    exp imp
    用法: exp 用户名/密码 file=存放导出数据的文件名 tables=(表名1,...表名N) log=记录导出过程的日志文件名
    imp 用户名/密码 file=导入数据所在的文件名 fromuser=源数据的用户名 touser=导入目标用户的用户名 log=记录导入过程的日志文件名

  10. 左/右连接 [选学]
    什么是左/右连接?
    用法: select a.* ,b.* from a left/right outer join B on(a.列名=b.列名)

  11. 存储过程[选学]
    什么是存储过程?
    有什么作用?
    用法: create or replace procedure 存储过程名(参数[参数可根据实际业务场景定])
    is
    begin
    存储过程何体;
    end 存储过程名;

posted @ 2020-11-21 15:15  ErShiXiong  阅读(75)  评论(0编辑  收藏  举报