刪除數據表
更新時間 2025-02-14 10:21:44
最近更新時間: 2025-02-14 10:21:44
分享文章
本文為您介紹如何刪除數據表。
刪除當前模式下的數據表。
teledb=# drop table t; DROP TABLE刪除某個模式下數據表。
teledb=# \d+ t Table "public.t" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description --------+---------+-----------+----------+---------+----------+--------------+------------- id | integer | | | | plain | | mc | text | | | | extended | | Distribute By: SHARD(id) Location Nodes: ALL DATANODES teledb=# \d+ t_as Table "public.t_as" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description --------+---------+-----------+----------+---------+----------+--------------+------------- id | integer | | | | plain | | mc | text | | | | extended | | Distribute By: SHARD(id) Location Nodes: ALL DATANODES teledb=# drop table public.test; DROP TABLE刪除數據表,不存在時不執行,不報錯。
teledb=# drop table IF EXISTS t; NOTICE: table "t" does not exist, skipping DROP TABLE使用CASCADE無條件刪除數據表。
teledb=# create view shardview as select * from test_shard; CREATE VIEW teledb=# drop table test_shard; ERROR: cannot drop table test_shard because other objects depend on it DETAIL: view shardview depends on table test_shard HINT: Use DROP ... CASCADE to drop the dependent objects too. teledb=# drop table test_shard cascade; NOTICE: drop cascades to view shardview DROP TABLE