2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-15 06:12:59 +00:00
cheat.sheets/sheets/_psql/update

28 lines
630 B
Plaintext
Raw Normal View History

2018-01-17 16:13:38 +00:00
-- Insert a new row into a table
2018-01-07 11:42:08 +00:00
INSERT INTO table(column1,column2,...)
VALUES(value_1,value_2,...);
2018-01-17 16:13:38 +00:00
-- Insert multiple rows into a table
2018-01-07 11:42:08 +00:00
INSERT INTO table_name(column1,column2,...)
VALUES(value_1,value_2,...),
(value_1,value_2,...),
(value_1,value_2,...)...
2018-01-17 16:13:38 +00:00
-- Update data for all rows
2018-01-07 11:42:08 +00:00
UPDATE table_name
SET column_1 = value_1,
...;
2018-01-17 16:13:38 +00:00
-- Update data for a set of rows specified by a condition in WHERE clause
2018-01-07 11:42:08 +00:00
UPDATE table
SET column_1 = value_1,
...
WHERE condition;
2018-01-17 16:13:38 +00:00
-- Delete all rows of a table
2018-01-07 11:42:08 +00:00
DELETE FROM table_name;
2018-01-17 16:13:38 +00:00
-- Delete specific rows based on a condition
2018-01-07 11:42:08 +00:00
DELETE FROM table_name
WHERE condition;