VOOZH about

URL: https://www.geeksforgeeks.org/python/python-sqlite-update-specific-column/

⇱ Python SQLite - Update Specific Column - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Python SQLite - Update Specific Column

Last Updated : 28 Apr, 2021

In this article, we will discuss how to update a specific column of a table in SQLite using Python.

In order to update a particular column in a table in SQL, we use the UPDATE query. The UPDATE statement in SQL is used to update the data of an existing table in the database. We can update single columns as well as multiple columns using UPDATE statement as per our requirement.

Syntax:

UPDATE table_name

SET column1 = value1, column2 = value2...., column n = value n

WHERE [condition];

Below are some examples which depict how to use UPDATE query in SQLite using Python.

Example 1: We are going to create a STUDENT table and then perform update operations in it by updating the SNAME of a student whose SID is 1 in the table.

Output:

👁 Image

Example 2:

Here is another program where we update the ADDRESS of all the rows whose SAGE column value is 22 in the same table.

Output:

👁 Image
Comment
Article Tags:
Article Tags: