Let’s start inserting data in the table created in our post, table name was employee, we also discussed how to check the table structure in one of our post
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 have created table
mysql> use demo;
Step 3) check the structure of the database
mysql> desc employee;
+————–+————–+——+—–+———+——-+
| Field | Type | Null | Key | Default | Extra |
+————–+————–+——+—–+———+——-+
| id | int(11) | YES | | NULL | |
| employeename | varchar(252) | YES | | NULL | |
| address | varchar(256) | YES | | NULL | |
+————–+————–+——+—–+———+——-+
3 rows in set (0.07 sec)
so this tells us that the table has 3 columns id , employeename and address , lets start by writing the insert statement syntax used will be
Insert into employee(id ,employeename , address) values ( 1, ‘DemoEmployee’, ‘US’) ;
mysql> Insert into employee(id ,employeename , address) values ( 1, ‘DemoEmployee’, ‘US’) ;
Query OK, 1 row affected (0.02 sec)
Lets check if the record is been inserted properly.
mysql> select * from employee;
+——+————–+———+
| id | employeename | address |
+——+————–+———+
| 1 | DemoEmployee | US |
+——+————–+———+
1 row in set (0.00 sec)
Excellent we have successfully inserted out first record.
