Is there a way to set the PRIMARY KEY in a single "CREATE TABLE AS" statement?
示例——我希望将以下内容写成一条语句,而不是两条:
CREATE TABLE "new_table_name" AS SELECT a.uniquekey, a.some_value + b.some_value FROM "table_a" AS a, "table_b" AS b WHERE a.uniquekey=b.uniquekey;
ALTER TABLE "new_table_name" ADD PRIMARY KEY (uniquekey);
一般来说,有没有更好的方法(假设有两个以上的表,例如10个)?