PostgreSQL中日期类型与字符串类型的转换方法
示例如下:
postgres=# select current_date;
date
------------
2015-08-31
(1 row)
postgres=# select to_char(current_date,'YYYYMMDD');
to_char
----------
20150831
(1 row)
字符串转换为日期
postgres=# select to_date('20150831','YYYYMMDD');
to_date
------------
2015-08-31
(1 row)
PostgreSQL命令行中使用变量的问题
postgres=# create table test_tb(id int);
CREATE TABLE
postgres=# select * from test_tb ;
id
(0 rows)
postgres=# \set var 10
postgres=# \echo :var
postgres=# insert into test_tb values (:var);
INSERT 0 1
postgres=# select * from test_tb ;
id
(1 row)
PostgreSQL中SELECT INTO操作创建临时表的问题
postgres=# select * from child ;
no | student_name | age | class_no
------------------+---------
1 | zhangsan | 11 | 1
2 | zhaosi | 11 | 1
3 | xiaoshenyang | 12 | 21
4 | songxiaobao | 13 | 21
5 | zhaobenshan | 31 | 1
6 | huoya | 41 | 2
7 | haha | 81 | 2
(7 rows)
postgres=# sele