有办法做到这一点吗?我想以下内容不起作用。
UPDATE表SET列=列+ 1 ...
除了编写函数或使用PHP之外,还有办法用查询吗?
答案 0 :(得分:11)
答案 1 :(得分:4)
它只会起作用:
# psql -U postgres
psql (9.0.1)
Type "help" for help.
postgres=# create database test;
CREATE DATABASE
postgres=# \c test
You are now connected to database "test".
test=# create table test (test integer);
CREATE TABLE
test=# insert into test values (1);
INSERT 0 1
test=# insert into test values (2);
INSERT 0 1
test=# select * from test;
test
------
1
2
(2 rows)
test=# update test set test = test + 1;
UPDATE 2
test=# select * from test;
test
------
2
3
(2 rows)