首先需要授權
sqlplus / as sysdba
grant create view to your_user;
然後建立表和儲存過程
drop table table1;create table TABLE1( user_id VARCHAR2(10), user_name VARCHAR2(10), user_mail VARCHAR2(10), user_mobile VARCHAR2(10), user_telephone VARCHAR2(10));CREATE OR REPLACE PROCEDURE CREATEVIEWS IS V_SQL VARCHAR2(10240);BEGIN V_SQL := "CREATE OR REPLACE VIEW V_TEST AS SELECT T1.USER_ID, T1.USER_NAME, --使用者姓名 T1.USER_MAIL, --使用者MAIL T1.USER_MOBILE, --使用者手機 T1.USER_TELEPHONE --使用者電話 FROM TABLE1 T1"; EXECUTE IMMEDIATE V_SQL;END CREATEVIEWS;/
執行,OK
SQL> exec createviews;PL/SQL procedure successfully completed
sqlplus / as sysdbagrant create view to your_user;然後建立表和儲存過程執行,OK
首先需要授權
sqlplus / as sysdba
grant create view to your_user;
然後建立表和儲存過程
drop table table1;create table TABLE1( user_id VARCHAR2(10), user_name VARCHAR2(10), user_mail VARCHAR2(10), user_mobile VARCHAR2(10), user_telephone VARCHAR2(10));CREATE OR REPLACE PROCEDURE CREATEVIEWS IS V_SQL VARCHAR2(10240);BEGIN V_SQL := "CREATE OR REPLACE VIEW V_TEST AS SELECT T1.USER_ID, T1.USER_NAME, --使用者姓名 T1.USER_MAIL, --使用者MAIL T1.USER_MOBILE, --使用者手機 T1.USER_TELEPHONE --使用者電話 FROM TABLE1 T1"; EXECUTE IMMEDIATE V_SQL;END CREATEVIEWS;/
執行,OK
SQL> exec createviews;PL/SQL procedure successfully completed