Delete an object from a database

Tell the server that you want to:

  • Delete a table
DROP TABLE <schema_name>.<table_name>;
  • Delete a schema
DROP SCHEMA <schema_name>;
IMPORTANT:
- Dropping something will remove it from the database server!
- Sometimes this command can fail if something else in the database depends on it existing
Example table

To practice, let's create a new table called aaa_Dummy_Table on our sequel-mart-schema and drop it:

CREATE TABLE "sequel-mart-schema"."aaa_Dummy_Table" (
	column_001 INT,
	column_002 VARCHAR(10),
	column_003 TIMESTAMP,
	column_004 NUMERIC(9,2)
);

This creates our table. We can query it:

SELECT *
FROM "sequel-mart-schema"."aaa_Dummy_Table";

Now let's remove (or DROP) it:

DROP TABLE "sequel-mart-schema"."aaa_Dummy_Table";

NOTE:

  • Because this statement can be applied to many other object types we cannot use the a shorthand
1. CREATE aaa_Dummy_Table 2. aaa_Dummy_Table included in database schema 3. SELECT FROM aaa_Dummy_Table 4. DROP aaa_Dummy_Table 5. aaa_Dummy_Table no longer in database schema