PG : 可以创建多个不同的索引,而且多个可以有用
postgres@:5432/postgres-95655#=create index idx_test on test(id);
CREATE INDEX
postgres@:5432/postgres-95655#=create index idx_test1 on test(id);
CREATE INDEX
postgres@:5432/postgres-95655#=create index idx_test2 on test(id);
CREATE INDEX
postgres@:5432/postgres-95655#=\d test
Table "public.test"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
id | integer | | |
v | integer | | |
Indexes:
"idx_test" btree (id)
"idx_test1" btree (id)
"idx_test2" btree (id)
PG: 使用中,可以含DDL命令。如下:
postgres@:5432/postgres-2414#=begin;
BEGIN
postgres@:5432/postgres-2414#=create table xx(id numeric);
CREATE TABLE
postgres@:5432/postgres-2414#=insert into xx values(10);
INSERT 0 1
postgres@:5432/postgres-2414#=\d
List of relations
Schema | Name | Type | Owner
--------+-------------------------+-------+----------
public | log_student | table | postgres
public | pg_buffercache | view | postgres
public | pg_stat_statements | view | postgres
public | pg_stat_statements_info | view | postgres
public | score | table | postgres
public | student | table | postgres
public | t | table | postgres
public | test | table | postgres
public | xx | table | postgres
(9 rows)
postgres@:5432/postgres-2414#=rollback;
ROLLBACK
postgres@:5432/postgres-2414#=\d
List of relations
Schema | Name | Type | Owner
--------+-------------------------+-------+----------
public | log_student | table | postgres
public | pg_buffercache | view | postgres
public | pg_stat_statements | view | postgres
public | pg_stat_statements_info | view | postgres
public | score | table | postgres
public | student | table | postgres
public | t | table | postgres
public | test | table | postgres
(8 rows)