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