[
Update Existing Table Data¶
Let us see how we can perform update operation to make changes to existing data inside a table.
- Typically we will have 2 clauses in update.
SET
clause where the columns that are supposed to be updated.- Optional
WHERE
clause where we specify the condition to filter for rows that need to be updated.
- As part of the
WHERE
clause generally we will have indexed column for performance reasons.
One need to have decent database and SQL skills to be comfortable with all types of application development. Feel free to Master SQL using Postgresql as target database using this course or playlist.
In [1]:
%run 05_function_get_database_connection.ipynb
In [13]:
%load_ext sql
The sql extension is already loaded. To reload it, use: %reload_ext sql
In [14]:
%env DATABASE_URL=postgresql://itversity_sms_user:itversity@pg.itversity.com:5432/itversity_sms_db
env: DATABASE_URL=postgresql://itversity_sms_user:itversity@pg.itversity.com:5432/itversity_sms_db
In [15]:
%%sql
SELECT user_id, user_role FROM users
WHERE user_id = 1
* postgresql://itversity_sms_user:***@pg.itversity.com:5432/itversity_sms_db 1 rows affected.
Out[15]:
user_id | user_role |
---|---|
1 | A |
]