如何创建不“由sys拥有"的表?在甲骨文? [英] How do I create tables not "owned by sys" in Oracle?
问题描述
我尝试创建触发器:
create trigger afterupdate
after insert on friends
for each row
begin
dbms_output.put_line('hello world');
end afterupdate;
但是出现以下错误:
"cannot create triggers on objects owned by SYS"
推荐答案
鉴于该错误,我假设您以SYS
身份登录数据库以创建表并编写代码.您不想为此使用SYS
架构-永远不要在SYS
架构中创建对象.您需要以其他用户身份登录数据库.通常,如果要构建全新的应用程序,则将创建一个新用户来拥有该新应用程序的所有对象.
Given the error, I am assuming that you are logging in to the database as SYS
to create your tables and to write your code. You do not want to use the SYS
schema for that-- you should never create objects in the SYS
schema. You'll need to log in to the database as a different user. In general, if you are building a brand new application, you would create a new user to own all the objects for the new application.
例如,如果您正在构建Facebook克隆,并且想要使用USERS
表空间来存储数据
For example, if you're building a Facebook clone and you want to use the USERS
tablespace for your data
CREATE USER facebook_appid
IDENTIFIED BY <<password>>
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP;
GRANT CREATE SESSION,
CREATE TABLE,
CREATE TRIGGER
TO facebook_appid;
然后您将使用指定的密码以facebook_appid
的身份连接到数据库.
You would then connect to the database as facebook_appid
using the password you specified.
sqlplus facebook_appid/<<password>>@<<TNS alias>>
完成此操作后,就可以创建表和触发器了.
Once you've done that, you can create the table and the trigger.
这篇关于如何创建不“由sys拥有"的表?在甲骨文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!