OracleXE

Aus SchnallIchNet
Wechseln zu: Navigation, Suche

create/alter user

sqlplus system@xe

(enter your system password)

create user testing identified by password;
create user production identified by password;
grant connect, resource to testing;
grant connect, resource to production;
exit

this is a simple example including a simple grant


CREATE USER testing IDENTIFIED BY password DEFAULT TABLESPACE MYTBLSPACE TEMPORARY TABLESPACE "TEMP";

more complex example incl. tablespaces


ALTER USER testing QUOTA UNLIMITED ON MYTBLSPACE;

change quota to unlimited


create/alter tablespace

CREATE TABLESPACE <tablespace_name> datafile '<path>' size 32m autoextend on next 32m maxsize 2048m extent management local;

to create a new tablespace...
datafile is full path to DB-file, e.g. /u01/app/oracle/oradata/XE/myTblSpace.dbf


grant

GRANT connect, create procedure, create session, create table, create type, create view, 
  create synonym,create sequence, create trigger, resource TO testing;

or:

GRANT DBA TO testing;


grant all privileges to testing;

grants ALL privileges to the user


grant create session, grant any privilege to testing;

grants the permission to log in and the GRANT permission to the user.
the user then is able to grant all available permissions to a user.


select * from system_privilege_map
  where name like '%PRIV%';

select actual privileges from DB


select count(*),grantee
 from dba_sys_privs
 where grantee in ('MDSYS','TESTING','PRODUCTION')
 group by grantee
/



show

sho user;

shows the username


show all;

shows all values


source files

to source a (pl/)sql file do

@/path/to/file.sql


import/export

Beispiel Full Import (die gesamte Datei wird importiert)

imp userid=system/manager file=full_exp.dmp
log=full_imp.log full=yes ignore=yes feedback=50

Nutzbar z.B. bei der Migration von einer Datenbankversion auf eine folgende (nur zwischen bestimmten Versionen möglich) oder von einem Betriebssystem auf ein anderes.

Vorsicht: In einem Full Export stehen Befehle zum Anlegen der Tablespaces inkl. der bereits erzeugten Dateien ("create tablespace" im Dump vorhanden). Beim Full Import wird dieser Befehl mit Parameter destroy=yes angewandt und falls die Dateien existieren, werden diese überschrieben.

Beim Full Export einer produktiven Datenbank und anschließendem Full Import in eine Testdatenbank auf dem gleichen Rechner wird mit destroy=yes die produktive Datenbank zerstört (Dateiname bleibt gleich). Beim Full Export unter Windows enthalten die Dateinamen die Laufwerksbuchstaben (z.B. "C:\..." ).


Beispiel Import mit Änderung des Benutzernamens

imp userid=system/manager file=pt_exp.dmp
log=pt_imp.log fromuser=protime touser=pt
ignore=yes feedback=50

Nutzbar z.B. bei der Änderung des Datenbankbenutzers oder der Kopie der Daten in das Schema eines anderen Benutzers zu Testzwecken.


Beispiel Import einer einzelnen Tabelle

imp userid=system/manager file=full_exp.dmp
log=full_imp.log fromuser=protime touser=pt tables=ma
ignore=yes feedback=50


Trouble-Shoot

yadda yadda...


Importing

Error:

ORA-01653: unable to extend table SYS.COM$ by 128 in tablespace SYSTEM

Solved by:
Exteding table-space SYSTEM:

alter tablespace SYSTEM add datafile '/u01/app/oracle/oradata/XE/system02.dbf' size 1000m;