简体   繁体   English

如何将列数据从一个表分离到另一个表?

[英]How to separate column data to copy from one table to other table?

I am using pgAdmin. 我正在使用pgAdmin。 I have two tables: STUDENT and STUD. 我有两张桌子:STUDENT和STUD。

  • STUD consists of a column DATE_TIME where the date and time are joined together. STUD由DATE_TIME列组成,其中日期和时间连接在一起。

  • STUDENT consists of two columns: DATE and TIME. STUDENT由两列组成:DATE和TIME。

I need to split the DATE_TIME from STUD table so that I can copy the DATE and TIME individually to STUDENT table. 我需要从STUD表中拆分DATE_TIME,这样我就可以将DATE和TIME分别复制到STUDENT表。

How do I do that? 我怎么做?

insert into student (date_col,time_col) select date_time::date, date_time::time from stud;

应该适合你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM