Skip to main content

SQL : inserting records into mysql table


To insert records into mysql tables use the insert into sql statement.The below insert statement add new records into the table pytable. Please refer to my previous post for table creation and table structure - sql-creating-tables-in-mysql

insert into pytable values(1,'Snikers','CH',NOW(),100.00);
insert into pytable values(2,'Galaxy','CO','2015-01-01',200.00);
insert into pytable values(3,'Butterfinger','CN',NOW(),150.00);




If the record addition is valid it will return the message

mysql> insert into pytable values(1,'Snikers','CH',NOW(),100.00);
Query OK, 1 row affected, 1 warning (0.04 sec)

mysql> insert into pytable values(2,'Galaxy','CO','2015-01-01',200.00);
Query OK, 1 row affected (0.03 sec)

mysql> insert into pytable values(3,'Butterfinger','CN',NOW(),150.00);
Query OK, 1 row affected, 1 warning (0.04 sec)



To view the records inserted use the select statement

mysql> select * from pytable;
+------+--------------+--------+------------+--------+
| pyid | pyname       | pycode | pydate     | pynum  |
+------+--------------+--------+------------+--------+
|    1 | Snikers      | CH     | 2016-08-05 | 100.00 |
|    2 | Galaxy       | CO     | 2015-01-01 | 200.00 |
|    3 | Butterfinger | CN     | 2016-08-05 | 150.00 |
+------+--------------+--------+------------+--------+
3 rows in set (0.00 sec)



Comments

Popular posts from this blog

Pokemon Go download link

Pokemon go has become the buzz word in tech industry now. Nintendo, the Japanese video game company are the creates of this game. Its first of it kind to integrate a game with augmented reality , so people has to go out to real world with there android or iPhone to catch em all . You can download  Pokemon go  from this link. 

UNIX : How to ignore lines with certain names

Sometimes we need to ignore multiple lines with certain words and get the list out of the file. usually it will be a log file to read . The below grep command can be used to ignore multiple words present in a text file. Lets say the file contain $ cat list.txt apple orange apple banana papaya Now we need to ignore line with orange , banana and papaya . So we can use the below grep command. $ cat list.txt | grep -Ev "orange|banana|papaya" apple apple It will ignore lines with the words in -v part of grep.