Leave no trace behind…

I am not suggesting you do this with any bad intention to “cover your tracks” and so no one is able to catch you. I recommend this for your learning/researching and most importantly, to think how to protect your environment from such activities.

To hide your activities in a Linux environment, you execute the following in the exact sequence:

No trace… pure evil… my question to you now is how do you stop someone from doing this to you, if you are the owner of your systems?

Auto increment ID in Oracle

Unfortunately, there is no auto increment id in Oracle until 12c. So for the older versions, you can model it easily with a sequence and a trigger like the following example:

CREATE TABLE departments (
ID NUMBER(10) NOT NULL,
DESCRIPTION VARCHAR2(50) NOT NULL);

ALTER TABLE departments ADD (
CONSTRAINT dept_pk PRIMARY KEY (ID));

CREATE SEQUENCE dept_seq START WITH 1;

CREATE OR REPLACE TRIGGER dept_bir
BEFORE INSERT ON departments
FOR EACH ROW

BEGIN
SELECT dept_seq.NEXTVAL
INTO :new.id
FROM dual;
END;
/

For 12c, you can do the following:

CREATE TABLE t1 (c1 NUMBER GENERATED BY DEFAULT ON NULL AS IDENTITY,
c2 VARCHAR2(10));

CREATE TABLE t1 (
c1 NUMBER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1),
c2 VARCHAR2(10)
);