In Our previous post we discussed how to create a database in MySQL , lets see how to create tables in MySQL database.
Step 1) Login to MySQL
we will be using user : demo and password as demouser
mysql -u demo -p demouser
Step 2) use database in which we need to create table , as in our previous post we created database demo we will be using same database
mysql> use demo;
Step 3) Create table lets assume our table will be called employee and it will have 2 columns id and employeename we are starting with very basic table structure and then will be adding more columns to it.
mysql> create table employee ( id int , employeename varchar(252) );
Query OK, 0 rows affected (0.01 sec)
step 4) Lets check that if table is created.
mysql> show tables;
+—————-+
| Tables_in_demo |
+—————-+
| employee |
+—————-+
1 row in set (0.00 sec)
so gr8 we are able to create our first table. in our next post we will discuss how to check the table structure and alter the table structure.