Drop Command

Create is DDL command that is used to create the database, table, view etc in SQL.

Syntax
DROP database_object database_object_name;


Drop Database

Drop database is used to delete the exist database else not exist it return ERROR 1008 (HY000): Can't drop database 'new_database'; database doesn't exist

Syntax
DROP Database database_name;
Example
mysql> DROP Database new_database;
Query OK, 1 row affected (0.09 sec)

mysql> DROP Database new_database;
ERROR 1008 (HY000): Can't drop database 'new_database'; database doesn't exist
mysql>
Create Table

Drop table is used to delete the exist table in database else table not exist it return ERROR 1051 (42S02): Unknown table 'staff'.

Syntax
DROP Table table_name;
Example
mysql> DROP Table staff;
Query OK, 0 rows affected (0.05 sec)

mysql> DROP Table staff;
ERROR 1051 (42S02): Unknown table 'staff'
mysql>
Drop View

Drop view is used to delete the exist view in database else view not exist it return ERROR 1051 (42S02): Unknown table 'new_view'.

Syntax
Drop View View_name;
Example
mysql> DROP View new_view;
Query OK, 0 rows affected (0.00 sec)

mysql> DROP View new_view;
ERROR 1051 (42S02): Unknown table 'new_view'
mysql>
Drop User

Drop user is used to delete the exist user in database else user not exist it return ERROR 1396 (HY000): Operation DROP USER failed for 'Master'@'%'.

Syntax
Drop User user_name;
Example
mysql> drop user 'sqluser';
Query OK, 0 rows affected (0.00 sec)

mysql> drop user 'sqluser';
ERROR 1396 (HY000): Operation DROP USER failed for 'sqluser'@'%'
mysql>