如何在向记录名称添加字符串并递增记录 ID 时克隆 Table 中的所有记录
How to Clone all records in a Table while adding a string to name of record and incrementing the record ID
我通过加入 2 个其他 table 和一个特定的 where 子句创建了一个新的 Table,这导致只有 169 条记录被添加到新的 table。
我现在需要做的是以下
- 将所有这些记录克隆到当前 table(重复)
向当前记录名称添加一个字符串
例子
原始记录名称:记录 1
克隆的记录名称:记录 1 - COPY
记录都有唯一的ID,克隆时,ID应该递增,但不能与其他记录的ID相同。
注意:这个新 TABLE 中的记录不是下面的连续示例
编号:bf378ee4-2430-264a-e7ec-546e68b12301
编号:bf378ee4-2430-264a-e7ec-546e68b12302
编号:bf378ee4-2430-264a-e7ec-546e68b12303
事实并非如此
Copy data to and from the same table and change the value of copied data in one column to a specified value
用于创建新的 TABLE
create table sgr_New.tim_time_temp_merged_and_purged as
SELECT * from sgr_New.tim_time as T
join sgr_New.tim_time_cstm as C
on T.id = C.id_c
where
(C.billable_time_c > "0")and
(C.unbillable_time_c > "0")and
(C.unbillable_reason_c not like "No_Unbillable_Time");
在网上找到这个(这是否相关)
很抱歉,我不得不指定所有字段的长查询,因为有一个特定字段我不应该插入。
insert into sgr_new.tim_time_temp_merged_and_purged (c1, c2, ...)
select
unpaid_billable_revenue_c,
unbilled_hours_c,
unbillable_time_c,
unbillable_reason_c,
training_time_c,
touched_c,
total_time_c,
time_netsuite_id_c,
time_entered_c,
tag_c,
requirements_time_c,
reporting_time_c,
related_account_c,
project_rate_c,
project_or_case_name_c,
project_number_c,
project_mgmt_time_c,
platform_build_time_c,
overrun_c,
num_minutes_c,
num_hours_c,
internal_notes_c,
free_hours_c,
expense_calculation_c,
expense_amount_c,
duration_c,
dev_time_c,
date_performed_c,
data_load_time_c,
currency_id,
counter_field_c,
configuration_time_c,
category_c,
case_rate_c,
case_number_c,
billing_rate_override_c,
billing_rate_c,
billing_notes_c,
billed_time_c,
billable_time_wf_copy_c,
billable_time_override_c,
billable_time_c,
billable_override_c,
billable_hours_kpi_c,
billable_c,
billable_amount_c,
base_rate,
amount_c,
account_short_name_c
from sgr_new.tim.time_cstm
where id = 1;
我希望看到
我的 Table 中的 338 条记录全部具有唯一 ID,没有重复项
其中 169 条已 "Copy" 添加到记录名称
我通过加入 2 个其他 table 和一个特定的 where 子句创建了一个新的 Table,这导致只有 169 条记录被添加到新的 table。
我现在需要做的是以下
- 将所有这些记录克隆到当前 table(重复)
向当前记录名称添加一个字符串 例子 原始记录名称:记录 1 克隆的记录名称:记录 1 - COPY
记录都有唯一的ID,克隆时,ID应该递增,但不能与其他记录的ID相同。
注意:这个新 TABLE 中的记录不是下面的连续示例
编号:bf378ee4-2430-264a-e7ec-546e68b12301
编号:bf378ee4-2430-264a-e7ec-546e68b12302
编号:bf378ee4-2430-264a-e7ec-546e68b12303
事实并非如此
Copy data to and from the same table and change the value of copied data in one column to a specified value
用于创建新的 TABLE
create table sgr_New.tim_time_temp_merged_and_purged as
SELECT * from sgr_New.tim_time as T
join sgr_New.tim_time_cstm as C
on T.id = C.id_c
where
(C.billable_time_c > "0")and
(C.unbillable_time_c > "0")and
(C.unbillable_reason_c not like "No_Unbillable_Time");
在网上找到这个(这是否相关) 很抱歉,我不得不指定所有字段的长查询,因为有一个特定字段我不应该插入。
insert into sgr_new.tim_time_temp_merged_and_purged (c1, c2, ...)
select
unpaid_billable_revenue_c,
unbilled_hours_c,
unbillable_time_c,
unbillable_reason_c,
training_time_c,
touched_c,
total_time_c,
time_netsuite_id_c,
time_entered_c,
tag_c,
requirements_time_c,
reporting_time_c,
related_account_c,
project_rate_c,
project_or_case_name_c,
project_number_c,
project_mgmt_time_c,
platform_build_time_c,
overrun_c,
num_minutes_c,
num_hours_c,
internal_notes_c,
free_hours_c,
expense_calculation_c,
expense_amount_c,
duration_c,
dev_time_c,
date_performed_c,
data_load_time_c,
currency_id,
counter_field_c,
configuration_time_c,
category_c,
case_rate_c,
case_number_c,
billing_rate_override_c,
billing_rate_c,
billing_notes_c,
billed_time_c,
billable_time_wf_copy_c,
billable_time_override_c,
billable_time_c,
billable_override_c,
billable_hours_kpi_c,
billable_c,
billable_amount_c,
base_rate,
amount_c,
account_short_name_c
from sgr_new.tim.time_cstm
where id = 1;
我希望看到 我的 Table 中的 338 条记录全部具有唯一 ID,没有重复项 其中 169 条已 "Copy" 添加到记录名称