-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb_commands.txt
55 lines (42 loc) · 1.46 KB
/
db_commands.txt
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
POSTGRES
--------
/opt/bmc/RLM/pgsql/bin/psql -U ef -h localhost -d e-finance_test -c "<sql statement>"
alter database "e-finance" rename to "e-finance_test"
create table users (id serial primary key, first_name varchar(255), last_name varchar(255));
insert into users (first_name, last_name) values ('Niek', 'Bartholomeus');
alter table users add column age int;
update users set age = 18;
alter table users drop column age;
# disconnect clients
SELECT pg_terminate_backend(pg_stat_activity.procpid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'e-finance' AND procpid <> pg_backend_pid();
ORACLE
------
-----------
CREATE TABLE USERS
(
ID NUMBER (10),
FIRST_NAME VARCHAR2 (255),
LAST_NAME VARCHAR2 (255)
)
NOCACHE
LOGGING;
CREATE SEQUENCE SEQ_USERS_ID START WITH 1
INCREMENT BY 1
MAXVALUE 9999999999999999999999999999
NOMINVALUE
NOORDER
NOCYCLE
CACHE 20;
CREATE OR REPLACE TRIGGER "E-FINANCE_TEST".TR_USERS_ID
BEFORE INSERT
ON "E-FINANCE_TEST".USERS
REFERENCING NEW AS new OLD AS old
FOR EACH ROW
BEGIN
SELECT "E-FINANCE_TEST".SEQ_USERS_ID.NEXTVAL INTO :new.ID FROM DUAL;
END;
-----------
insert into users (first_name, last_name) values ('Niek', 'Bartholomeus');
alter table users add age int;
update users set age = 18;
alter table users drop column age;