PostgreSQL DML Operations: Difference between revisions
Jump to navigation
Jump to search
(→INSERT) |
No edit summary |
||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=Internal= | =Internal= | ||
* [[PostgreSQL Operations]] | * [[PostgreSQL Operations]] | ||
* [[SQL#SQL_Data_Statements_(DML)|SQL Data Statements (DML)]] | |||
=<TT>INSERT</TT>= | =<TT>INSERT</TT>= | ||
{{Internal|SQL_INSERT#Overview|Standard SQL <tt>INSERT</tt>}} | {{Internal|SQL_INSERT#Overview|Standard SQL <tt>INSERT</tt>}} | ||
<syntaxhighlight lang='sql'> | <syntaxhighlight lang='sql'> | ||
INSERT INTO | INSERT INTO person (id, name) VALUES (10, 'Bob') | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Double quotes can be used around column names. | |||
Use single quotes for the string values. Double quotes will let the SQL interpreter think you use a column name. | |||
=<TT>UPDATE</TT>= | =<TT>UPDATE</TT>= | ||
{{Internal|SQL_UPDATE#Overview|Standard SQL <tt>UPDATE</tt>}} | |||
<syntaxhighlight lang='sql'> | <syntaxhighlight lang='sql'> | ||
UPDATE | UPDATE person SET id=50 WHERE name='Bob' | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Double quotes can be used around column names. | |||
=<TT>DELETE</TT>= | =<TT>DELETE</TT>= | ||
{{Internal|SQL_DELETE#Overview|Standard SQL <tt>DELETE</tt>}} | |||
<syntaxhighlight lang='sql'> | <syntaxhighlight lang='sql'> | ||
DELETE FROM | DELETE FROM person WHERE id=10 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Double quotes can be used around column names. | |||
=<TT>SELECT</TT>= | =<TT>SELECT</TT>= | ||
{{Internal|SQL_SELECT#Overview|Standard SQL <tt>SELECT</tt>}} | |||
<syntaxhighlight lang='sql'> | <syntaxhighlight lang='sql'> | ||
SELECT " | SELECT "id", "name" FROM person | ||
</syntaxhighlight> | </syntaxhighlight> |
Latest revision as of 19:32, 24 May 2024
Internal
INSERT
INSERT INTO person (id, name) VALUES (10, 'Bob')
Double quotes can be used around column names.
Use single quotes for the string values. Double quotes will let the SQL interpreter think you use a column name.
UPDATE
UPDATE person SET id=50 WHERE name='Bob'
Double quotes can be used around column names.
DELETE
DELETE FROM person WHERE id=10
Double quotes can be used around column names.
SELECT
SELECT "id", "name" FROM person