postgresql一个有趣的现象

编程入门 行业动态 更新时间:2024-10-05 03:28:03

postgresql一个<a href=https://www.elefans.com/category/jswz/34/1764111.html style=有趣的现象"/>

postgresql一个有趣的现象

作者:瀚高PG实验室 (Highgo PG Lab)-徐云鹤
在postgresql中线创建一张表,

highgo=# create table abcd (int int);
CREATE TABLE

然后再创建一张表,列的数据类型使用刚刚创建的表名。

	highgo=# create table abcde (abcd abcd);CREATE TABLE

创建成功了。
创建的每一个表都会同时生成同名的类型?

highgo=# select * from pg_type where typname='abcd';typname | typnamespace | typowner | typlen | typbyval | typtype | typcategory | typispreferred | typisdefined | typdelim | typrelid | typelem | typarray | typinput  |typoutput  | typreceive  |   typsend   | typmodin | typmodout | typanalyze | typalign | typstorage | typnotnull | typbasetype | typtypmod | typndims | typcollation | 
typdefaultbin | typdefault | typacl 
---------+--------------+----------+--------+----------+---------+-------------+----------------+--------------+----------+----------+---------+----------+-----------+
------------+-------------+-------------+----------+-----------+------------+----------+------------+------------+-------------+-----------+----------+--------------+-
--------------+------------+--------abcd    |         2200 |       10 |     -1 | f        | c       | C           | f              | t            | ,        |    17993 |       0 |    17994 | record_in |record_out | record_recv | record_send | -        | -         | -          | d        | x          | f          |           0 |        -1 |        0 |            0 | |            | 
(1 row)

尝试删除此表。

highgo=# drop table abcd;
错误:  2BP01: 无法删除 表 abcd 因为有其它对象倚赖它
DETAIL:  表 abcde 字段 abcd 倚赖于 类型 abcd
HINT:  使用 DROP .. CASCADE 把倚赖对象一并删除.
highgo=# drop table abcd cascade;
注意:  00000: 递归删除 表 abcde 字段 abcd
DROP TABLE
highgo=# select * from abcde;
--
(0 rows)

厉害了word哥。
查查还有这个类型不?

highgo=# select * from pg_type where typname='abcd';typname | typnamespace | typowner | typlen | typbyval | typtype | typcategory | typispreferred | typisdefined | typdelim | typrelid | typelem | typarray | typinput | 
typoutput | typreceive | typsend | typmodin | typmodout | typanalyze | typalign | typstorage | typnotnull | typbasetype | typtypmod | typndims | typcollation | typdefa
ultbin | typdefault | typacl 
---------+--------------+----------+--------+----------+---------+-------------+----------------+--------------+----------+----------+---------+----------+----------+-
----------+------------+---------+----------+-----------+------------+----------+------------+------------+-------------+-----------+----------+--------------+--------
-------+------------+--------
(0 rows)

有点意思。

更多推荐

postgresql一个有趣的现象

本文发布于:2024-02-06 15:32:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1749981.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有趣   现象   postgresql

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!