SQL DATABASE Keyword
The DATABASE keyword is used with SQL commands like CREATE
and DROP
to manage whole databases. You can create new databases to store tables and data separately or delete existing ones when they are no longer needed.
SQL CREATE DATABASE Syntax
CREATE DATABASE database_name
SQL CREATE DATABASE Example
This statement creates a new database named testDB
.
CREATE DATABASE testDB;
Note: This command will not work in SQLite including our TechKubo playground. In SQLite, databases are created as individual files outside SQL, usually through our application or file system. The playground automatically loads a built-in database that you can use without needing to create one.
SQL SHOW DATABASES Syntax
This command is used to list all available databases.
SHOW DATABASES;
Note: This command is not supported in SQLite. It works in systems like MySQL.
SQL DROP DATABASE Syntax
DROP DATABASE database_name;
SQL DROP DATABASE Example
This deletes the entire database named testDB
, including all its tables and data.
DROP DATABASE testDB;
Note: This command is also not supported in SQLite. In SQLite, you delete a database by deleting the file manually from your file system.