DROP TABLE IF EXISTS "public"."gen_table";
时间: 2023-08-09 14:12:42 浏览: 63
DROP TABLE IF EXISTS "public"."gen_table";是一个SQL语句,用于删除名为"gen_table"的表。这个语句会首先检查是否存在这个表,如果存在则将其删除。[1]请注意,这个语句只会删除表的结构,而不会删除表中的数据。如果您想要删除表中的数据,请使用DELETE语句。
相关问题
set hive.exec.dynamic.partition.mode=nonstrict; set hive.exec.parallel=true; set hive.exec.parallel.thread.number=30; --drop table if exists dm_finrisk.dm_event_walletSettleSuccessEvent_di; create table if not exists dm_finrisk.dm_event_cashLoanEvent_di( event_uuid string ,event_code string ,dt string ,event_time string ,rawSnapshot string ) COMMENT 'cashLoanEvent' PARTITIONED BY ( day bigint)stored as parquet; drop table if exists tmp.tmp_dm_event_cashLoanEvent_di_01_${zdt.addDay(-1).format("yyyyMMdd")}; create table if not exists tmp.tmp_dm_event_cashLoanEvent_di_01_${zdt.addDay(-1).format("yyyyMMdd")} as select uuid as event_uuid ,event as event_code ,from_unixtime(unix_timestamp(cast(day as string),'yyyymmdd'),'yyyy-mm-dd') as dt ,from_unixtime(cast(cast(`time` AS BIGINT)/1000 AS BIGINT),'yyyy-MM-dd HH:mm:ss') as event_time ,get_json_object(data,'$.hotPublish.rawSnapshot') as rawSnapshot from dm_finrisk.ods_event_hdfs_snapshot_di where code = 'shield@cashLoanEvent' and day=${zdt.addDay(-1).format("yyyyMMdd")} drop table if exists tmp.tmp_dm_event_cashLoanEvent_di_02_${zdt.addDay(-1).format("yyyyMMdd")}; create table if not exists tmp.tmp_dm_event_cashLoanEvent_di_02_${zdt.addDay(-1).format("yyyyMMdd")} as select event_uuid ,event_code ,dt ,event_time ,rawSnapshot from tmp.tmp_dm_event_cashLoanEvent_di_01_${zdt.addDay(-1).format("yyyyMMdd")}; alter table dm_finrisk.dm_event_cashLoanEvent_di drop if exists partition (day = ${zdt.addDay(-1).format("yyyyMMdd")}); insert overwrite table dm_finrisk.dm_event_cashLoanEvent_di partition (day = ${zdt.addDay(-1).format("yyyyMMdd")}) select event_uuid ,event_code ,dt ,event_time ,rawSnapshot from tmp.tmp_dm_event_cashLoanEvent_di_02_${zdt.addDay(-1).format("yyyyMMdd")}分析下上面代码
上面的代码主要是一个HiveQL脚本,用于从`dm_finrisk.ods_event_hdfs_snapshot_di`表中提取`code`为`shield@cashLoanEvent`且`day`为昨天日期的数据,并将其存储到`dm_finrisk.dm_event_cashLoanEvent_di`表中的对应分区中。
具体来说,该脚本的执行步骤如下:
1. 第1行:设置Hive执行参数,包括动态分区模式、并行执行和并行执行线程数等。
2. 第3-8行:创建`dm_finrisk.dm_event_cashLoanEvent_di`表,该表包含5个列,分别为`event_uuid`、`event_code`、`dt`、`event_time`和`rawSnapshot`,其中`dt`为分区列。
3. 第10-15行:创建临时表`tmp.tmp_dm_event_cashLoanEvent_di_01_${zdt.addDay(-1).format("yyyyMMdd")}`,该表从`dm_finrisk.ods_event_hdfs_snapshot_di`表中选择`code`为`shield@cashLoanEvent`且`day`为昨天日期的记录,并将其中的`uuid`、`event`、`day`、`time`和`data`字段分别映射到`event_uuid`、`event_code`、`dt`、`event_time`和`rawSnapshot`列中。
4. 第17-22行:创建临时表`tmp.tmp_dm_event_cashLoanEvent_di_02_${zdt.addDay(-1).format("yyyyMMdd")}`,该表从临时表`tmp.tmp_dm_event_cashLoanEvent_di_01_${zdt.addDay(-1).format("yyyyMMdd")}`中选择所有列,用于后续的数据处理。
5. 第24行:如果`dm_finrisk.dm_event_cashLoanEvent_di`表中昨天的分区已经存在,则删除该分区。
6. 第26-27行:将临时表`tmp.tmp_dm_event_cashLoanEvent_di_02_${zdt.addDay(-1).format("yyyyMMdd")}`中的数据插入到`dm_finrisk.dm_event_cashLoanEvent_di`表的昨天分区中。
整个脚本的作用是将来自`dm_finrisk.ods_event_hdfs_snapshot_di`表的特定数据提取出来,并存储到`dm_finrisk.dm_event_cashLoanEvent_di`表的对应分区中,以便后续的分析和查询。
CREATE TABLE IF NOT EXISTS CDBILSDBA.T_SUBJECT_TEMPLATE_CONFIG
这是一条 SQL 语句,用于在 CDBILSDBA 数据库中创建 T_SUBJECT_TEMPLATE_CONFIG 表。如果该表已经存在,则不执行创建操作。该表可能用于存储课题模板的配置信息。需要根据实际需求定义表的结构和约束条件,以确保数据的完整性和一致性。例如,可以使用 CREATE TABLE 语句定义列名、数据类型、主键、外键、唯一性约束等。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)