Skip to content

Instantly share code, notes, and snippets.

@vmleon
Created January 28, 2021 16:18
Show Gist options
  • Save vmleon/3cffbc2be7b53171448969b19808e949 to your computer and use it in GitHub Desktop.
Save vmleon/3cffbc2be7b53171448969b19808e949 to your computer and use it in GitHub Desktop.
Oracle DB Security Redaction: create schema, table, insert items and enable ORDS
CREATE USER APP IDENTIFIED BY "Str0nP4ssw0rd!";
GRANT CONNECT, RESOURCE TO APP;
GRANT UNLIMITED TABLESPACE TO APP;
CREATE TABLE APP.USERS (
ID NUMBER
GENERATED BY DEFAULT ON NULL AS IDENTITY,
NAME VARCHAR2(25),
CARD_NUMBER VARCHAR2(25)
);
CREATE UNIQUE INDEX USERS_ID_PK ON
APP.USERS (
ID
);
ALTER TABLE APP.USERS ADD (
CONSTRAINT USERS_ID_PK PRIMARY KEY ( ID )
);
INSERT INTO APP.USERS (NAME,CARD_NUMBER) VALUES ('John', '1234-4321-5678-8765');
INSERT INTO APP.USERS (NAME,CARD_NUMBER) VALUES ('Martin', '1234-4321-5678-5432');
BEGIN
ORDS.ENABLE_SCHEMA(
P_ENABLED => TRUE,
P_SCHEMA => 'APP',
P_URL_MAPPING_TYPE => 'BASE_PATH',
P_URL_MAPPING_PATTERN => 'app',
P_AUTO_REST_AUTH => TRUE
);
COMMIT;
END;
/
BEGIN
ORDS.ENABLE_OBJECT(
P_ENABLED => TRUE,
P_SCHEMA => 'APP',
P_OBJECT => 'USERS',
P_OBJECT_TYPE => 'TABLE',
P_OBJECT_ALIAS => 'users',
P_AUTO_REST_AUTH => FALSE
);
COMMIT;
END;
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment