DEV Community

vidhya murali
vidhya murali

Posted on

PostgreSQL DROP & DELETE

Day - 4

DDL vs DML Commands

DDL — Data Definition Language

  • it defines or change the structure of a database.
  • we use DDL to create, modify and delete the structure like table and columns

Ex :

CREATE - used to create a new table or database
ALTER - to change the existing structure
DROP - to delete the complete object, table, column
TRUNCATE - to remove all the rows from the table

DML — Data Manipulation Language

It is used to manipulate the datas and rows inside a table

Ex:

INSERT -to add new data
UPDATE - to modify the Existing data
DELETE - to delete the existing rows

DELETE- DML

DELETE removes rows (data) from a table

Note: Be careful when deleting records in a table! Notice the WHERE clause in the DELETE statement. The WHERE clause specifies which record(s) should be deleted.

If you omit the WHERE clause,
all records in the table will be deleted!.

DROP-DDL

DROP removes the entire database object.

DROP TABLE employee;
Enter fullscreen mode Exit fullscreen mode

The DROP TABLE statement is used to drop an existing table in a database.

DELETE → ROW delete
TRUNCATE → ALL ROWS delete
DROP TABLE → ENTIRE TABLE delete
DROP COLUMN → COLUMN delete

Top comments (0)