C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
SQLite Insert QueryIn SQLite, INSERT INTO statement is used to add new rows of data into a table. After creating the table, this command is used to insert data into the table. There are two types of basic syntaxes for INSERT INTO statement: Syntax1: INSERT INTO TABLE_NAME [(column1, column2, column3,...columnN)] VALUES (value1, value2, value3,...valueN); Here, column1, column2, column3,...columnN specifies the name of the columns in the table into which you have to insert data. You don't need to specify the columns name in the SQlite query if you are adding values to all the columns in the table. But you should make sure that the order of the values is in the same order of the columns in the table. Then the syntax will be like this: Syntax2: INSERT INTO TABLE_NAME VALUES (value1,value2,value3,...valueN); Let's take an example to demonstrate the INSERT query in SQLite database. We have already created a table named "STUDENT". Now enter some records in that table. Inserting values by first method: INSERT INTO STUDENT (ID,NAME,AGE,ADDRESS,FEES) VALUES (1, 'Ajeet', 27, 'Delhi', 20000.00); INSERT INTO STUDENT (ID,NAME,AGE,ADDRESS,FEES) VALUES (2, 'Akash', 25, 'Patna', 15000.00 ); INSERT INTO STUDENT (ID,NAME,AGE,ADDRESS,FEES) VALUES (3, 'Mark', 23, 'USA', 2000.00 ); INSERT INTO STUDENT (ID,NAME,AGE,ADDRESS,FEES) VALUES (4, 'Chandan', 25, 'Banglore', 65000.00 ); INSERT INTO STUDENT (ID,NAME,AGE,ADDRESS,FEES) VALUES (5, 'Kunwar', 26, 'Agra', 25000.00 ); Second Method: You can also insert the data into the table by second method. INSERT INTO STUDENT VALUES (6, 'Kanchan', 21, 'Meerut', 10000.00 ); Output: You can see the output by using the SELECT statement: SELECT * FROM STUDENT;
Next TopicSQLite Select Query
|