During the past two days, Oracle triggers are learned. When you create a trigger, you may encounter an error message "you cannot create a trigger for objects owned by sys.
User logon is a self-created new user XXX login, and then XXX user creates a tablespace named MECITY, create a table named citys in the mecity tablespace under the XXX user.
Then, create a trigger for the CITY table so that the ID column of the table is automatically increased by 1 each time data is inserted.
Trigger creation statement:
Create trigger TRI_CITY_ID
BEFORE INSERT ON CITYS
FOR EACH ROW
BEGIN
SELECT CITY_ID.NEXTVAL INTO: NEW. id from citys;
END;
Error prompt: ORA-O4O89: unable to create a trigger for objects owned by sys.
First, find the table in tables and right-click the table to view its properties, which contains the owner. In this case, the owner must be sys.
The following provides a solution:
Create a table with the same name as the table for the current login user, and copy the data from the table sys. For example:
Create table xxx. citys as select * from sys. CITYS;
Delete the table under sys.
Drop table sys. CITYS;
Then execute the create trigger statement.