Saturday, October 19, 2019

SQLite UPDATE Query

In SQLite, UPDATE query is used to modify the existing records in a table. It is used with WHERE clause to select the specific row otherwise all the rows would be updated.
Syntax:
  1. UPDATE table_name  
  2. SET column1 = value1, column2 = value2...., columnN = valueN  
  3. WHERE [condition];   
Example:

We have an existing table named "STUDENT", having the following data:
Sqlite Update query 1
Example1:
Update the ADDRESS of the student where ID is
  1. UPDATE STUDENT SET ADDRESS = 'Noida' WHERE ID = 1;   
Sqlite Update query 2
Now the address is updated for the id 1. You can check it by using SELECT statement:
  1. SELECT * FROM STUDENT;  
Output:
Sqlite Update query 3
Example2:
If you don't use WHERE clause, it will modify all address in the STUDENT table:
  1. UPDATE STUDENT SET ADDRESS = 'Noida';   
Output:
Sqlite Update query 4

No comments:

Post a Comment

How to DROP SEQUENCE in Oracle?

  Oracle  DROP SEQUENCE   overview The  DROP SEQUENCE  the statement allows you to remove a sequence from the database. Here is the basic sy...