Create Tables
Learn how to create tables in a database.
We'll cover the following...
Showing tables
As we learned in our introduction to RDBMS, a database can have many tables. How can we get the list of tables of the current database, though? This is done with the help of the show tables
; command. When we issue the command on the customers_db
database, we get the output Empty set
, which means the action was completed successfully with no results to show. That’s why we should get Succeeded
in the result box of the following query:
show tables;
When we practice this command in the terminal, we get the following output:
The server tells us that customers_db
doesn’t have any tables by giving us the result Empty set
. This is because customers_db
is a database that we just created. We haven’t created a table yet.
Note: When we hit “Ctrl+L” while on the
mysql>
prompt, it will clear the terminal, and the prompt will appear at the top. This is handy to clear the terminal window and proceed with new commands.
It’s almost time to design and create our first database table. Below is the command that would create the table ...