简体   繁体   中英

how to create view in oracle sql 11g

SQL> CREATE VIEW  "[my_view]" as select ename, sal from emp where sal>2000;

CREATE VIEW "[my_view]" as select ename, sal from emp where sal>2000 * ERROR at line 1: ORA-01031: insufficient privileges

SQL> select * from "[my_view]";

select * from "[my_view]" * ERROR at line 1: ORA-00942: table or view does not exist

This is my code. Whats wrong with me?

[ ] are not allowed in view name while creating them, your query should look like this

create view My_View as select ename, sal from emp where sal>2000;

For more info please refer to docs

我不确定您是否可以将 [ ] 添加到视图名称中,请尝试使用“[My_View]”,但您也必须使用“[My_View]”进行选择。

Oracle does not use brackets for identifier "quotation". Correct syntax is:

create view my_view as ...

or

create view "MY_VIEW" as ..

Using quotation does create the view by exact that name including upper and lower case while without it it will be transformed to the database standard case setting. Using Oracle my_view will be MY_VIEW .

EDIT: Additional you need the create any view privilege to create a view. I assume you have only a user on your tablespace, that is allowed to use views but not to create one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM