Avatar billede fredand Forsker
13. december 2010 - 15:47 Der er 2 kommentarer og
1 løsning

How to create a table under a user

Hello!

I got a problem by creating tables under a user.

I first created a database with oracle universell installer.

I then loged in to it with Toad as SYS and created:

CREATE USER my_user IDENTIFIED BY my_password;

Then I thought that tables etc will be assigned to my_user if I log out SYS and log in as my_user in Toad.

My idea was to do:

CREATE TABLE Countries
(
    id INT NOT NULL,
    name VARCHAR(255) NOT NULL,
    PRIMARY KEY (id)
);

CREATE SEQUENCE Sequence_Countries_id
START WITH 1
INCREMENT BY 1
NOMAXVALUE;

CREATE TRIGGER Trigger_Countries_id
BEFORE INSERT ON Countries
FOR EACH ROW
BEGIN
    SELECT Sequence_Countries_id.NEXTVAL INTO :NEW.ID FROM DUAL;
END;


But when I get to CREATE TRIGGER Trigger_Countries_id I get an error saying, "can not create triggers for object belonging to SYS"

Do you huys see if I'm missing something.

Do need something called tablespace?

Best regards
Fredrik
Avatar billede teepee Nybegynder
13. december 2010 - 16:06 #1
just write create table my_user.countries - you need the prefix or to login as the user, i.e. log into the schema where you want the tables put
Avatar billede teepee Nybegynder
13. december 2010 - 16:07 #2
You probably need to:
grant ressource, connect to my_user;
Avatar billede fredand Forsker
13. december 2010 - 16:17 #3
Aha!

I still was loged in as SYSDBA.
I also added:
grant create session to dbinspector_user;

Now it seems that I log in as correct user and can create my tables etc.

Best regards
Fredrik
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Computerworld tilbyder specialiserede kurser i database-management

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester