๊ด€๋ฆฌ ๋ฉ”๋‰ด

JiYoung Dev ๐Ÿ–ฅ

[database ๊ณ ๊ธ‰] CTAS (2023.08.08) ๋ณธ๋ฌธ

full stack/database

[database ๊ณ ๊ธ‰] CTAS (2023.08.08)

Shinjio 2023. 8. 8. 17:00

๋ฐฑ์—… ํ…Œ์ด๋ธ” ์ƒ์„ฑ

 

CTAS : CREATE TABLE AS SELECT(CTAS) SELECT ๋ฌธ์˜ ๊ฒฐ๊ณผ๋กœ๋ถ€ํ„ฐ ์ƒˆ ํ…Œ์ด๋ธ”์„ ์ƒ์„ฑํ•œ๋‹ค.

 

CREATE TABLE TB_CUST_BAK AS SELECT * FROM TB_CUST; 
--๋ฐ์ดํ„ฐ์™€ ์ž๋ฃŒํ˜•๊นŒ์ง€ ํ•œ๋ฒˆ์— ๋“ค์–ด๊ฐ(PK, FK ๋ณต์‚ฌ๋Š” ๋ถˆ๊ฐ€)

 

 

CREATE TABLE TB_CUST_BAK AS SELECT * FROM TB_CUST WHERE 1=0; 
-- TB_CUST์™€ ๋˜‘๊ฐ™์€ ํ˜•ํƒœ์˜ ํ…Œ์ด๋ธ” ์ƒ์„ฑ (๋ฐ์ดํ„ฐ X)