postgresql 通過一個表創建一個新表


PG根據已有表建立新表

 

AS(通用)

create table test(id serial, name varchar(10));
insert into test(name) values('a'),('b'),('c');
create table test2 as select * from test;

 

PG特有

-- 注意,test3應該是還沒創建的新表
select * into test3 from test;
create table test_t2 (like test_t1); --只創建表結構

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM