oracle管理常用命令整理(二)

本文介绍了Oracle数据库中表及索引的管理方法,包括表列的删除、表重命名、使用CTAS创建表、创建临时表、索引组织表等操作。此外,还详细讲解了如何创建不同类型的分区表,以及如何维护分区表,例如增加、删除分区等。

删除表列

--删除列

alter table test01 drop (a);

--标记列为无用后删除(对大数据量的列)

alter table test01 set unused(a,b);

alter table test01 drop unused columns;

alter table test01 drop unused columns checkpoint 1000; --减少undo的产生

[@more@]

重命名

--重命名表

alter table test01 rename to test02

--重命名列

alter table test01 rename column a to b;

使用CTAS创建表

create table test02

as select * from test01

parallel degree 4 --使用并行创建,提高创建速度

nologging; --不写重做日志,提高创建速度

创建临时表

create global temporary table temp_tab(a number)

--on commit preserve rows; --对整个会话保留数据

--on commit delete rows; --对整个事物保留数据(默认)

创建索引组织表

create table idx_tab(

id number,

name varchar2(20),

constraint pk_id primary key(id))

organiztion index

pctthreshold 25 --预留空间阀值

overflow tablespace overflow_tables; --溢出数据存放的表空间

创建分区表

--创建范围分区表

create table range_tab

(id number,

year int not null,

month int not null)

partition by range(year,month)

(partition p1 values less than(2008,04) tablespace ts1,

partition p2 values less than(2008,07) tablespace ts2,

partition p3 values less than(2008,10) tablespace ts3,

partition p4 values less than(2009,01) tablespace ts4);

--创建散列分区表

create table hash_tab

(id number,

year int not null,

month int not null)

partition by hash(id)

partitions 4

store in(ts1,ts2,ts3,ts4);

--创建列表分区表

create table list_tab

(id number,

city varchar2(20))

partition by list(city)

(partition north values('BJ','DL') tablespace ts1,

partition south values('SH','HZ')) tablespace ts2;

--创建范围-散列分区表

create table range_hash_tab

(x number,

y number)

partition by range(x) subpartition by hash(y)

subpartitions 8 store in (ts1,ts2,ts3,ts4) --总共32个分区

(partition p1 values less than (1000),

partition p2 values less than (2000),

partition p3 values less than (3000),

partition p4 values less than (maxvalue));

--创建范围-列表分区

create table range_list_tab --总共4个分区

(id number,

day date,

city varchar2(20))

partition by range(day)

subpartition by list(city)

(partition p1 values less than (to_date('2008-04-01','yyyy-mm-dd')) tablespace ts1

(subpartition p1_north values ('BJ','DL'),

subpartition p1_south values ('SH','HZ')),

partition p2 values less than (to_date('2008-07-01','yyyy-mm-dd')) tablespace ts2

(subpartition p2_north values ('BJ','DL'),

subpartition p2_south values ('SH','HZ')));

维护分区表

--增加分区

alter table range_tab

add partition p5 values less than (2009,04)

tablespace ts5;

--分割分区(散列无法使用

alter table range_tab

split partition p1 at (2008,02) into --at后跟分割界限

(partition p5,partition p6); --必须是新的分区名

--合并分区(散列无法使用)

alter table range_tab

merge partitions p5,p6 into

p1; --可以是新的分区也可以是已存在的分区

--重命名分区

alter table rename partition p1 to p5;

--交换分区

alter table range_tab exchange partition p1 with table t1;

--删除分区(散列无法使用)

alter table rang_tab

drop partition p1

--update global indexes; --更新全局索引,否则无效

--接合分区(范围和列表无法使用)

alter table hash_tab coalesce partition; --减少一个分区

快速获取创建对象的DDL语句

select dbms_metadata.get_ddl('TABLE','TEST') from dual;

--括号中分别为对象类型和对象名,注意大小写

创建集群

--创建集群

create cluster emp_dept(deptno number(3));

--HASH IS deptno HASHKEY 200; --散列集群,200表示散列值的数量

--将表加入创建的集群中

craete table dept(deptno number(3) primary key)

cluster emp_dept (deptno);

create table emp(empno number(5) primary key,

deptno number(3) references dept)

cluster emp_dept(deptno);

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10176825/viewspace-1018008/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10176825/viewspace-1018008/

基于可靠性评估序贯蒙特卡洛模拟法的配电网可靠性评估研究(Matlab代码实现)内容概要:本文围绕“基于可靠性评估序贯蒙特卡洛模拟法的配电网可靠性评估研究”,介绍了利用Matlab代码实现配电网可靠性的仿真分析方法。重点采用序贯蒙特卡洛模拟法对配电网进行长时间段的状态抽样与统计,通过模拟系统元件的故障与修复过程,评估配电网的关键可靠性指标,如系统停电频率、停电持续时间、负荷点可靠性等。该方法能够有效处理复杂网络结构与设备时序特性,提升评估精度,适用于含分布式电源、电动汽车等新型负荷接入的现代配电网。文中提供了完整的Matlab实现代码与案例分析,便于复现和扩展应用。; 适合人群:具备电力系统基础知识和Matlab编程能力的高校研究生、科研人员及电力行业技术人员,尤其适合从事配电网规划、运行与可靠性分析相关工作的人员; 使用场景及目标:①掌握序贯蒙特卡洛模拟法在电力系统可靠性评估中的基本原理与实现流程;②学习如何通过Matlab构建配电网仿真模型并进行状态转移模拟;③应用于含新能源接入的复杂配电网可靠性定量评估与优化设计; 阅读建议:建议结合文中提供的Matlab代码逐段调试运行,理解状态抽样、故障判断、修复逻辑及指标统计的具体实现方式,同时可扩展至不同网络结构或加入更多不确定性因素进行深化研究。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值