두 테이블이 있다고 가정 해 봅시다. 양쪽에 동시에 행을 삽입하는 방법이 있습니까? 내가 한 테이블에 있었을 때 나는 단순히 어떻게 모두 한 번에 삽입 할, 지금 한 이메일을 저장하는 테이블 및 성과 이름을 저장하는 관련 테이블이있는 경우Postgres에서 INSERT INTO와 연관 사용
INSERT INTO users (first_name, last_name, email) VALUES ('Tom','Prats','[email protected]'), ('Tim', 'Prats', [email protected]);
을 할 수 있습니까? 많은 데이터를 가져오고 있음을 명심하십시오.
Table "users" Column | Type | Modifiers ---------------------+---------------+----------- id | character(36) | not null email | text | Indexes: "pk_users" PRIMARY KEY, btree (id) Foreign-key constraints: "fk_users_attributes" FOREIGN KEY (attributes_id) REFERENCES user_attributes(id)
Table "user_attributes" Column | Type | Modifiers -----------------+---------------+----------- id | character(36) | not null first_name | text | last_name | text | Indexes: "pk_user_attributes" PRIMARY KEY, btree (id) Referenced by: TABLE "users" CONSTRAINT "fk_users_attributes" FOREIGN KEY (attributes_id) REFERENCES user_attributes(id)
을 사용할 수 있습니다, 그래서 WITH' 도움이 될'생각하지 않는다, 그러나 이것은 제가 사전에 두 테이블의 기본 키를 생성 할 수 실현할 수 있도록 않았다 그래서 나는 그것들을 따로 따로 삽입 할 때 관련이있을 것이다. –