To drop a table, and all the other objects that depend on it, use one of these. (Views, for example.) The second will not throw an error if the table doesn't exist, but it will still throw an error if other database objects depend on it. Most often, the other database objects will be foreign key references, but there may be others, too. Postgres=# DROP TABLE IF EXISTS table_name The first one will throw an error if the table doesn't exist, or if other database objects depend on it. "IF EXISTS" is not standard different platforms might support it with different syntax, or not support it at all. (10 rows) Step 2.Next we will drop the "t5" tableĭROP TABLE Step 3.Here we are are dropping mulltiple table in a single commandĭROP TABLE Step 4.after dropped the table we need to verfy the table using "\dt" command Public | us_snail_addy | table | postgres Step 1. First you need to list down the tables and choose what table do you want to drop and also check that table having any dependencies like index,foregin key,trigger,functions,or any procedure Refuse to drop the table if any objects depend on it. The name (optionally schema-qualified) of the table to drop.Īutomatically drop objects that depend on the table (such as views). 1 Answer Sorted by: 2 delete/drop a table if another table exists That would be: do begin if exists (select 1 from informationschema.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |