-
Notifications
You must be signed in to change notification settings - Fork 2
/
emp.sql
23 lines (20 loc) · 1.05 KB
/
emp.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
CREATE TABLE IF NOT EXISTS emp (
id INTEGER NOT NULL PRIMARY KEY,
name VARCHAR,
age INTEGER,
gender VARCHAR,
boss VARCHAR,
email VARCHAR
);
CREATE SEQUENCE emp_id;
UPSERT INTO EMP VALUES( NEXT VALUE FOR emp_id, 'alice', 31, 'M', 'dave', '[email protected]');
UPSERT INTO EMP VALUES( NEXT VALUE FOR emp_id, 'bob', 28, 'M', 'dave', '[email protected]');
UPSERT INTO EMP VALUES( NEXT VALUE FOR emp_id, 'candy', 31, 'M', 'dave', '[email protected]');
UPSERT INTO EMP VALUES( NEXT VALUE FOR emp_id, 'dave', 31, 'M', 'george', '[email protected]');
CREATE INDEX emp_idx0 ON emp(age DESC) include (name,boss) async;
CREATE INDEX emp_idx1 ON emp(name DESC) include (gender,boss) async;
CREATE INDEX emp_idx2 ON emp(name DESC, email) include (age,boss) async;
UPSERT INTO EMP VALUES( NEXT VALUE FOR emp_id, 'edword', 0, 'M', 'dave', '[email protected]');
UPSERT INTO EMP VALUES( NEXT VALUE FOR emp_id, 'ford', 1, 'M', 'dave', '[email protected]');
UPSERT INTO EMP VALUES( NEXT VALUE FOR emp_id, 'george', 255, 'M', 'dave', '[email protected]');
SELECT * FROM EMP;