Skip to content

Instantly share code, notes, and snippets.

@joshbode
Created August 16, 2013 22:48
Show Gist options
  • Select an option

  • Save joshbode/6254167 to your computer and use it in GitHub Desktop.

Select an option

Save joshbode/6254167 to your computer and use it in GitHub Desktop.
Create tables in a schema
@echo off
setlocal enableextensions
pushd "%~p1"
set FILENAME="%~n1"
echo @%FILENAME% exit; | sqlplus -l -s /nolog
popd
pause
SET ESCAPE ON
SET SERVEROUTPUT ON SIZE UNLIMITED
SET LINESIZE 32767
SET VERIFY OFF FEEDBACK OFF ECHO OFF
SET NEWPAGE 0 PAGESIZE 0 TRIMSPOOL ON HEADING OFF
-- ignore existing tables
WHENEVER SQLERROR CONTINUE
BEGIN
DBMS_OUTPUT.PUT_LINE('----------------------------------------------------------------------------');
DBMS_OUTPUT.PUT_LINE('Creating tables in ' || LOWER('&_user') || '@&_CONNECT_IDENTIFIER');
DBMS_OUTPUT.PUT_LINE('----------------------------------------------------------------------------');
END;
/
@@ users;
CONNECT /@DB.world; -- uses wallet authentication to database
CREATE TABLE abc123 (
n INTEGER
);
GRANT SELECT, INSERT, UPDATE, DELETE ON abc123 TO &FOO_USERS;
-- user groups
DEFINE FOO_USERS = "andy, jimmy"
DEFINE BAR_USERS = "kylie"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment