sql快速创建一张相同表结构的表

根据t_bond_basic_info表,创建表结构相同的表,取老表中的一部分字段t_bond_basic_info_new 后面的条件 where id>146000 创建的时候把id>146000的数据写到新表中,如果where 1<>1,只创建表结构,不把数据写进去

CREATE TABLE t_bond_basic_info_new select 
id,
bond_uni_code,
bond_code,
bond_short_name,
bond_full_name,
com_uni_code,
iss_name,
iss_start_date,
iss_end_date,
year_pay_date,
year_pay_matu,
inte_start_date,
theo_end_date,
inte_pay_freq,
inte_pay_cls_par,
exer_pay_date,
plan_iss_amut,
actu_iss_amut,
bond_matu,
bond_type_par,
cred_uni_code,
rate_type_par,
rate_des,
iss_coup_rate,
base_rate_par,
list_date,
list_decl_date,
sec_mar_par,
coll_cap_purp,
unde_name,
unde_cls_par,
iss_cls,
iss_cls_des,
iss_pri,
iss_status,
is_new,
bond_iss_year,
iss_decl_date,
iss_obj,
is_public_iss,
iss_fee_rate,
bokep_date,
debt_reg_date,
new_size,
subs_unit,
least_subs_unit,
cury_type_par,
is_list_par,
trade_unit,
circu_amut,
is_cros_mar_par,
cros_mar_des,
list_sect_par,
list_sta_par,
theo_delist_date,
last_trade_date,
actu_delist_date,
spe_short_name,
eng_full_name,
eng_short_name,
isin_code,
curr_status,
bond_par_val,
is_type_par,
bond_form_par,
actu_end_date,
inte_des,
new_coup_rate,
ref_yield,
init_base_rate_date,
base_rate,
opt_extra_spr,
extra_spr_seq_num,
rate_ceil,
rate_floor,
inte_calcu_cls_par,
is_segm_par,
inte_pay_meth,
simp_comp_inte_par,
repay_cls_pay_par,
matu_pay_date,
pay_fee_rate,
pay_matu,
pay_cls_des,
opt_des,
is_guar_par,
is_repu_par,
pledge_code,
pledge_name,
is_redem_par,
is_resa_par,
is_hedge_par,
is_tax_free_par,
matu_unit_par,
gura_name,
gura_name1,
iss_sta_par,
bond_id,
create_user,
last_update_user,
create_time,
last_update_time,
'0' as del_status,
1 as data_source
from t_bond_basic_info
where id>146000

根据t_bond_primary_info表,创建表结构相同的表,取老表中的一部分字段t_bond_primary_info_new

CREATE TABLE t_bond_primary_info_new select 
id,
bond_uni_code,
bond_full_name,
pay_start_date,
pay_end_date,
desc_pay_date,
distribution_start_date,
distribution_end_date,
exer_remark,
plan_iss_scale,
plan_iss_scale_unit,
plan_iss_amut_unit,
actu_fir_iss_amut,
actu_fir_iss_amut_unit,
actu_iss_amut_unit,
bond_matu_des,
new_rate,
iss_cred_level,
cred_org_uni_code,
rate_writ_date,
iss_cred_date,
bas_spr,
iss_cls_type,
book_start_date,
book_end_date,
book_manager,
subscription_rate,
min_subscription_count,
subscription_period_start_date,
subscription_period_end_date,
subscription_time_description,
subscription_interval_lower,
subscription_interval_super,
tender_bid,
tender_type,
full_court_mult,
marginal_mult,
bid_date,
did_interval_low,
did_interval_sup,
stop_bid_start_date,
stop_bid_end_date,
cancel_issue_date,
push_status,
edit_status,
del_status,
create_user,
create_time,
last_update_user,
last_update_time
from t_bond_primary_info
where id>2500

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券