I have the following table images
id,image,download,type
1,url1,0,'extra'
2,url2,0,'main'
3,url3,1,'extra'
I am copying some of it's data for testing purposes into temp1
and giving the id
"p_key" using
select * into temp1 from images where download=0 order by id offset 0 limit 1000000;
then
alter table temp1 add constraint temp1_pk primary key (id);
is there a way of combining the two commands into 1 command?
There is no need to combine these two statements into one, and from a performance perspective it is preferrable to add the constraint after you insert the data.
So execute both statements in a single transaction, and you will have all the benefits of combining the statements:
BEGIN;
/* your statements */
COMMIT;
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加