Learn What is Database? How to Create and Show Databases using SQL

Learn What is Database? How to Create and Show Databases using SQL


In this lecture we will Learn how to create and display databases in SQL. The databases are created by using CREATE DATABASE statement. A valid database name may contain only letters, numbers and underscore symbol. The database name must contain at least one alphabet letter. The database names are always stored in small letters. Its good practice to name the database with some meaningful characters, like company name, website name business name etc. The existing databases are displayed by using the “SHOW DATABASE” statement. These are the SQL statements to create and display databases. Lets Learn how to create and display databases with some practical examples. I’ve logged in my MySQL database server by using my root username and password. First of all lets display all the existing databases using SQL statement, “SHOW DATABASES;” The system displays all the test database created by us in previous sections. And also MySQL default system databases like, information_schema, mysql, performance_schema and sys databases. These MySQL system databases stores, MySQL users information, privileges rules and other database related settings. Lets create a new database called ‘MY_DATABASE’ all in capital letters. The SQL statement will be, “CREATE DATABASE MY_DATABASE;” Press enter to create the database, and display all the existing databases again, using SQL statement, “SHOW DATABASES;” And you can see, the new database has been created but the name is in all lowercase. Though, we typed our new database name in all capital letters, the system automatically converted and stored the database name in lowercase. Now, If I try to create another database with name ‘1234’ using SQL statement, “CREATE DATABASE 1234;” and press enter to execute the SQL statement, the system won’t save the database name with all numeric character. We will need at least 1 alphabet character to save the name. So, we can modify the statement as, “CREATE DATABASE 1234d;” Press enter to execute the SQL statement, and this time the database was successfully created. We can confirm the database created by displaying all the databases using, “SHOW DATABASES;” statement. And sure enough the new database “1234d” was successfully created.

Danny Hutson

1 thought on “Learn What is Database? How to Create and Show Databases using SQL

Leave a Reply

Your email address will not be published. Required fields are marked *