zoukankan      html  css  js  c++  java
  • Oracle数据库基本概念理解(2)

    --删除用户
    drop user sz cascade;
    --创建表空间
    create tablespace worktablsp
    datafile 'C:applenovooradataorclEMPTB.dbf' SIZE 5M
     AUTOEXTEND ON;
    --修改表空间
    ALTER tablespace worktablsp 
    ADD datafile 'C:applenovooradataorclEMPTB.dbf' SIZE 5M;
     --扩展数据文件大小
     ALTER database 
     datafile 'C:applenovooradataorclEMPTB.dbf' RESIZE 6M;
     --删除
     DROP TABLESPACE worktablsp INCLUDING CONTENTS and datafiles
    --创建用户:
    CREATE USER RH
    IDENTIFIED BY HR
    DEFAULT  TABLESPACE tablespace  ;
    
    --给用户授权:
      GRANT CONNECT TO RH;  --连接数据库角色
    GRANT SELECT ON SCOTT.EMP TO RH;--查看SCOTT.EMP表的权限
     --分区表
     --范围分区
     create table saletb
     (
       saleid number ,
       productid number,
       saleDate date not null
     )
     partition  by range(saleDate)
     (
       partition p1 values less than(to_date('2013-01-01','yyyy-mm-dd')),
       partition p2 values less than(to_date('2014-01-01','yyyy-mm-dd')),
       partition p3 values less than(to_date('2015-01-01','yyyy-mm-dd')),
       partition p4 values less than(maxvalue)     
     );
     select * from saletb;
     insert into saletb values(1,1,to_date('2012-01-01','yyyy-mm-dd'));
    
      insert into saletb values(2,2,to_date('2013-06-01','yyyy-mm-dd'));
      insert into saletb values(3,3,to_date('2014-10-01','yyyy-mm-dd'));
      insert into saletb values(4,4,to_date('2016-01-01','yyyy-mm-dd'));
         
      select * from saletb partition(p3);
     --间隔分区 一个季度(三个月)一个分区
     CREATE TABLE SALES2
    (
       SALES_ID NUMBER,
       PRODUCT_ID VARCHAR2(5),
       SALES_DATE DATE NOT NULL
    )
    		PARTITION BY RANGE(SALES_DATE)
    		INTERVAL(NUMTOYMINTERVAL(3,'MONTH'))
    		(PARTITION P1 VALUES LESS THAN (to_date('2013-04-1','yyyy/mm/dd')));
        --
        select * from sales2;
    --插入数据
    	INSERT INTO sales2 VALUES (1,'a',to_date('2013-08-1','yyyy/mm/dd'));
      INSERT INTO sales2 VALUES (3,'c',to_date('2013-02-1','yyyy/mm/dd'));
      --查看分区数据
     select * from sales2 partition(sys_p41);
     --获得分区情况
    	SELECT table_name,partition_name 
       	  FROM user_tab_partitions 
    	 WHERE table_name=UPPER('sales2');
       
       
       
       
    

  • 相关阅读:
    【leetcode】1630. Arithmetic Subarrays
    【leetcode】1629. Slowest Key
    【leetcode】1624. Largest Substring Between Two Equal Characters
    【leetcode】1620. Coordinate With Maximum Network Quality
    【leetcode】1619. Mean of Array After Removing Some Elements
    【leetcode】1609. Even Odd Tree
    【leetcode】1608. Special Array With X Elements Greater Than or Equal X
    【leetcode】1603. Design Parking System
    【leetcode】1598. Crawler Log Folder
    Java基础加强总结(三)——代理(Proxy)Java实现Ip代理池
  • 原文地址:https://www.cnblogs.com/a1111/p/12816418.html
Copyright © 2011-2022 走看看