In my previous post, I
explained how to create a table. In this post, I am going to show how to insert
data into table employee.
Following is my
employee table structure.
mysql> describe employee; +-------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | id | int(11) | YES | | NULL | | | name | varchar(20) | YES | | NULL | | +-------+-------------+------+-----+---------+-------+ 2 rows in set (0.00 sec)
By using INSERT INTO
statement, you can insert records into a table.
mysql> INSERT INTO employee VALUES (1, "Hari Krishna"); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO employee VALUES (2, "Gopi"); Query OK, 1 row affected (0.00 sec)
You can also specify
the fields order, while inserting.
mysql> INSERT INTO employee (name, id) VALUES ("Sudhir", 3); Query OK, 1 row affected (0.00 sec) mysql> SELECT * FROM employee; +------+--------------+ | id | name | +------+--------------+ | 1 | Hari Krishna | | 2 | Gopi | | 3 | Sudhir | +------+--------------+ 3 rows in set (0.00 sec)
No comments:
Post a Comment