blob: 5b7c03575fdf92e9f5f3568d4685b7bce13cccf9 (
plain)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
drop table computer_terms;
ERROR: Relation 'computer_terms' does not exist
create table computer_terms(term text, category text, comments char(16));
create index computer_terms_index1 on computer_terms using btree(term);
create index computer_terms_index2 on computer_terms using btree(category);
insert into computer_terms values('computer display', 'X-A01-Y', 'a comment 1');
insert into computer_terms values('computer graphics', 'T-B01-Y', 'a comment 2');
insert into computer_terms values('computer programmer', 'S-Z01-Y', 'a comment 3');
vacuum computer_terms;
select * from computer_terms;
term | category | comments
---------------------+----------+------------------
computer display | X-A01-Y | a comment 1
computer graphics | T-B01-Y | a comment 2
computer programmer | S-Z01-Y | a comment 3
(3 rows)
select * from computer_terms where category = 'X-A01-Y';
term | category | comments
------------------+----------+------------------
computer display | X-A01-Y | a comment 1
(1 row)
select * from computer_terms where category ~* 'x-a01-y';
term | category | comments
------------------+----------+------------------
computer display | X-A01-Y | a comment 1
(1 row)
select * from computer_terms where category like '_-A01-_';
term | category | comments
------------------+----------+------------------
computer display | X-A01-Y | a comment 1
(1 row)
select * from computer_terms where category like '_-A%';
term | category | comments
------------------+----------+------------------
computer display | X-A01-Y | a comment 1
(1 row)
select * from computer_terms where term ~ 'computer [dg]';
term | category | comments
-------------------+----------+------------------
computer display | X-A01-Y | a comment 1
computer graphics | T-B01-Y | a comment 2
(2 rows)
select * from computer_terms where term ~* 'computer [DG]';
term | category | comments
-------------------+----------+------------------
computer display | X-A01-Y | a comment 1
computer graphics | T-B01-Y | a comment 2
(2 rows)
select *,character_length(term) from computer_terms;
term | category | comments | char_length
---------------------+----------+------------------+-------------
computer display | X-A01-Y | a comment 1 | 16
computer graphics | T-B01-Y | a comment 2 | 17
computer programmer | S-Z01-Y | a comment 3 | 19
(3 rows)
select *,octet_length(term) from computer_terms;
term | category | comments | octet_length
---------------------+----------+------------------+--------------
computer display | X-A01-Y | a comment 1 | 16
computer graphics | T-B01-Y | a comment 2 | 17
computer programmer | S-Z01-Y | a comment 3 | 19
(3 rows)
select *,position('s' in term) from computer_terms;
term | category | comments | strpos
---------------------+----------+------------------+--------
computer display | X-A01-Y | a comment 1 | 12
computer graphics | T-B01-Y | a comment 2 | 17
computer programmer | S-Z01-Y | a comment 3 | 0
(3 rows)
select *,substring(term from 10 for 4) from computer_terms;
term | category | comments | substr
---------------------+----------+------------------+--------
computer display | X-A01-Y | a comment 1 | disp
computer graphics | T-B01-Y | a comment 2 | grap
computer programmer | S-Z01-Y | a comment 3 | prog
(3 rows)
|