postgresql数据类型转换


有3种方法进行转换

1.通过格式化函数进行转换

  • to_char
  • to_date
  • to_number
  • to_timestamp

2通过CAST函数进行转换()

 

 3通过::操作符转换

postgres=# select oid,relname from pg_class where relname='test_json1';
  oid  |  relname
-------+------------
 16462 | test_json1
(1 row)

postgres=# select attname from pg_attribute where attrelid='test_json1' and attnum>0;
ERROR:  invalid input syntax for type oid: "test_json1"
LINE 1: select attname from pg_attribute where attrelid='test_json1'...
                                                        ^
postgres=# select attname from pg_attribute where attrelid='test_json1'::regclass and attnum>0;
 attname
---------
 id
 name
(2 rows)

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM