当前位置:Gxlcms > 数据库问题 > Postgresql流水帐(第五天):增删查改

Postgresql流水帐(第五天):增删查改

时间:2021-07-01 10:21:17 帮助过:3人阅读

(1, ‘Cheese‘, 9.99),

(2, ‘Bread‘, 1.99),

(3, ‘Milk‘, 2.99);

可以一次插入多行数据。

INSERT INTO products (product_no, name, price) VALUES (1, ‘Cheese‘, DEFAULT);

INSERT INTO products DEFAULT VALUES;

INSERT INTO products (product_no, name) VALUES (1, ‘Cheese‘);

INSERT INTO products VALUES (1, ‘Cheese‘);

插入默认值,从左向右赋值,无值的或未指定值的赋默认值,或显式把所有列赋默认值。

?

?

删:delete

DEDELETE FROM products;

LETE FROM products WHERE price = 10;

删除满足where条件的记录或

删除所有记录(如果不提供where条件)

?

?

改:update

To update existing rows, use the?UPDATE?command. This requires three pieces of information:

  1. The name of the table and column to update
  2. The new value of the column
  3. Which row(s) to update

?

UPDATE mytable SET a = 5, b = 3, c = 1 WHERE a > 0;

UPDATE products SET price = price * 1.10;

可以更新所有记录,也可以更新某条记录,取决于where条件。

可以更新多个字段。

如果没有记录满足where条件,不报错。

?

查:select

Postgresql流水帐(第五天):增删查改

标签:

人气教程排行