DBA Hub

📋Steps in this guide1/1

Create/drop index commands in postgres

-- Simple create index: postgres=# create index tab_idx2 on scott.customer(emp_name); CREATE INDEX

postgresql configurationintermediate
by PostgreSQL
14 views
1

Create/drop index commands in postgres

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
-- Simple create index:
postgres=#
create index tab_idx2 on scott.customer(emp_name);
CREATE INDEX
-- Create index with tablespace:
postgres#
CREATE INDEX tab_idx2 on scott.customer(emp_name) TABLESPACE IND_TS;
CREATE INDEX
-- Create index without causing blocking:
postgres=#
create index concurrently tab_idx2 on scott.customer(emp_name) TABLESPACE IND_TS;
CREATE INDEX
-- Create unique index:
postgres=#
create unique index tab_idx2 on scott.customer(emp_name)
CREATE INDEX
-- Create functional index:
postgres=#
create index fun_idx on scott.customer(lower(emp_name));
CREATE INDEX
-- Create multi column index:
postgres=#
create index multi_idx on scott.customer(emp_name,emp_id);
CREATE INDEX
-- drop an index:
postgres=#
drop index fun_idx;
DROP INDEX

Comments (0)

Please to add comments

No comments yet. Be the first to comment!