zoukankan      html  css  js  c++  java
  • oracle常用命令

    --以本机示例:
    --全局数据库名: muna
    --SID: haha
    --用户: znn(权限 connect ,resource,dba)
    --表空间:haha_data 及临时表空间 haha_temp
    --oracle内部有两个建好的用户:system和sys

    --查询数据库中的所有用户
    select * from dba_users;
    

      

    --查询所有的表空间
    select tablespace_name, sum(bytes) / 1024 / 1024
    from dba_data_files
    group by tablespace_name;
    --或
    select * from dba_tablespaces;
    

      

    --查询当前用户所属的表空间
    select username,default_tablespace from user_users;
    

    --删除一个表中的全部数据,使用drop table,delete * from 表名时,tablespace表空间该表的战胜空间并未释放,
    --反复几次drop,delete操作后,该tablespace上百兆的空间就被耗光了。
    truncate table table_name;

    --创建临时表空间
    create temporary tablespace haha_temp
    tempfile 'D:appxxxoradata	esthaha_temp01.dbf'
    size 50m 
    autoextend on 
    next 50m maxsize 20480m
    extent management local;
    

      

    --创建表空间
    create tablespace haha_data 
    logging datafile 'D:appxxxoradata	esthaha_data01.dbf'
    size 32m 
    autoextend on 
    next 32m maxsize 2048m
    extent management local;
    

      

    --创建用户并指定表空间
    create user znn identified by 123
    default tablespace haha_data
    temporary tablespace haha_temp;
    

      

    --给用户授予权限
    grant connect ,resource,dba to znn;
    

      

    -- 创建序列 Create sequence 
    create sequence SEQ_TEST
    minvalue 1000000000
    maxvalue 9999999999
    start with 1000000001
    increment by 1
    cache 20
    nocycle;
    

      

    --创建触发器
    create or replace trigger trg_test 
    before insert on znn_test01
    for each row 
    begin
      if(:new.cert_type='01') then
      :new.cert_type := '0';
      elsif(:new.cert_type='02') then
      :new.cert_type := '1';
      end if;
    end;
    --行触发器与语句触发器区别:
    --1、行触发器有for each row子句,语句触发器没有
    --2、行解决器可以有when作为触发限制,可以使用new/old。语句触发器不能有when作为触发限制
    --3、行触发器对应DML语句所影响到的表中的每一行,触发器都要执行一遍。
    -- 而语句触发器,对应DML语句所影响到的表中的所有行,触发器只执行一遍。



  • 相关阅读:
    基于散列的集合 HashSetHashMapHashTable
    英文工作邮件
    英语日常口语
    统计数组中各个元素出现的次数,元素取值范围为:1到N
    编写一个程序,指定一个文件夹,能自动计算出其总容量
    四则运算随机生成100题
    常用异常处理情况
    第三讲 动手动脑-2
    第三讲 动手动脑-1
    使用类的静态字段和构造函数,可以跟踪某个类所创建对象的个数。请写一个类,在任何时候都可以向它查询“你已经创建了多少个对象
  • 原文地址:https://www.cnblogs.com/amunamuna/p/7794193.html
Copyright © 2011-2022 走看看