oracle数据库判断表是否存在,存在删除,并创建新表

本文介绍如何在Oracle数据库中检查并删除指定表,随后创建一个用于记录光伏设备功率及电压屏蔽值的新表,并对其各字段进行了注释说明。
-判断表是否存在,存在就删除
declare
 v_exists number;
begin
    selectcount(*)intov_exists fromuser_tables wheretable_name = 'LLT_CONSUMERPVSHIELDRECORD';
    if v_exists > 0 then
    executeimmediate 'drop table LLT_CONSUMERPVSHIELDRECORD';
    endif;
        
end;
/
--创建PV屏蔽值记录表
createtable LLT_PVSHIELDRECORD
(
  id             CHAR(32)notnull,
  yearmonth       NUMBER(6),
  psr_id         CHAR(32),
  datatime       DATE,
  p_originalvalueFLOAT,
  p_replacevalue FLOAT,
  v_originalvalueFLOAT,
  v_replacevalue FLOAT
);
-- Add comments to the columns
commentoncolumn LLT_PVSHIELDRECORD.id
  is'ID';
commentoncolumn LLT_PVSHIELDRECORD.yearmonth
  is'所属月份';
commentoncolumn LLT_PVSHIELDRECORD.psr_id
  is'设备ID';
commentoncolumn LLT_PVSHIELDRECORD.datatime
  is'时间';
commentoncolumn LLT_PVSHIELDRECORD.p_originalvalue
  is'有功功率原始值';
commentoncolumn LLT_PVSHIELDRECORD.p_replacevalue
  is'有功功率替换值';
commentoncolumn LLT_PVSHIELDRECORD.v_originalvalue
  is'电压原始值';
commentoncolumn LLT_PVSHIELDRECORD.v_replacevalue
  is'电压替换值';
  altertable LLT_PVSHIELDRECORD
  addconstraint XPK_LLT_PVSHIELDRECORD primarykey (ID);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值