SQL 错误:表空间不存在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29341921/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SQL Error: Tablespace does not exist
提问by Soham Banerjee
I am running this script on sql oracle developer:-
我在 sql oracle developer 上运行这个脚本:-
DEFINE TABLESPACE1 = "&TABLESPACE1";
CREATE TABLE "DBUSER"
(
"USER_ID" VARCHAR2(100 BYTE),
"USERNAME" VARCHAR2(100 BYTE),
"CREATED_BY" VARCHAR2(100 BYTE),
"CREATED_DATE" DATE
) TABLESPACE "&TABLESPACE1" ;
I am getting this error:-
我收到此错误:-
SQL Error: ORA-00959: tablespace '&TABLESPACE1' does not exist
00959. 00000 - "tablespace '%s' does not exist"
采纳答案by Lalit Kumar B
NOTENot all SQL*Plus
commands are necessary to run in SQL Developer. Also, it depends on the SQL Developer version, the latest versions have a lot of SQL*Plus commands support.
注意并非所有SQL*Plus
命令都需要在SQL Developer 中运行。此外,这取决于 SQL Developer 版本,最新版本有很多 SQL*Plus 命令支持。
I tested in SQL Developer version 3.2.20.10
我在SQL Developer 版本 3.2.20.10 中测试过
&
is used for substitution variablein SQL*Plus
.
&
用于替换变量在SQL*Plus
。
For example,
例如,
In SQL*Plus
在 SQL*Plus
SQL> DEFINE TABLESPACE1 = &TABLESPACE1
Enter value for tablespace1: new_tablespace
SQL> SELECT '&TABLESPACE1' from dual;
old 1: SELECT '&TABLESPACE1' from dual
new 1: SELECT 'new_tablespace' from dual
'NEW_TABLESPAC
--------------
new_tablespace
SQL>
In SQL Developer
在SQL 开发人员中
DEFINE TABLESPACE1 = &TABLESPACE1
<Enter the value when prompted> -- I entered "t"
old:DEFINE TABLESPACE1 = &TABLESPACE1
new:DEFINE TABLESPACE1 = t
SQL Error: ORA-00959: tablespace '&TABLESPACE1' does not exist
- 00000 - "tablespace '%s' does not exist"
SQL 错误:ORA-00959:表空间“&TABLESPACE1”不存在
- 00000 - “表空间 '%s' 不存在”
Are you sure you are executing it as a scriptin SQL Developer. You could press F5to execute it as a script. Did you substitute the value for the variable?
您确定要在SQL Developer中将其作为脚本执行吗?您可以按 F5将其作为脚本执行。您是否替换了变量的值?
For example,
例如,
SQL> DEFINE TABLESPACE1 = "&TABLESPACE1"
Enter value for tablespace1: new_tablespace
SQL> CREATE TABLE "DBUSER"
2 (
3 "USER_ID" VARCHAR2(100 BYTE),
4 "USERNAME" VARCHAR2(100 BYTE),
5 "CREATED_BY" VARCHAR2(100 BYTE),
6 "CREATED_DATE" DATE
7 ) TABLESPACE "&TABLESPACE1" ;
old 7: ) TABLESPACE "&TABLESPACE1"
new 7: ) TABLESPACE "new_tablespace"
) TABLESPACE "new_tablespace"
*
ERROR at line 7:
ORA-00959: tablespace 'new_tablespace' does not exist
SQL>
In your case, if the value is properly substituted, and if tablespace exists, you should be able to create the table.
在您的情况下,如果该值被正确替换,并且表空间存在,您应该能够创建该表。
回答by Petr Pribyl
It looks like you entered a value '&TABLESPACE1' into TABLESPACE1 substitution variable. Maybe you have substitution scanning off. Try
看起来您在 TABLESPACE1 替换变量中输入了一个值“&TABLESPACE1”。也许你有替代扫描关闭。尝试
SET SCAN ON
before your statement
在你的陈述之前
回答by Norbert Rieger
My solution:
我的解决方案:
DROP TABLE "DBUSER";
UNDEFINE TABLESPACE1
DEFINE TABLESPACE1 = 'USERS'
CREATE TABLE "DBUSER"
(
"USER_ID" VARCHAR2(100 BYTE),
"USERNAME" VARCHAR2(100 BYTE),
"CREATED_BY" VARCHAR2(100 BYTE),
"CREATED_DATE" DATE
) TABLESPACE "&TABLESPACE1." ;
/
SQL> DROP TABLE "DBUSER";
UNDEFINE TABLESPACE1
DEFINE TABLESPACE1 = 'USERS'
CREATE TABLE "DBUSER"
(
"USER_ID" VARCHAR2(100 BYTE),
"USERNAME" VARCHAR2(100 BYTE),
"CREATED_BY" VARCHAR2(100 BYTE),
"CREATED_DATE" DATE
) TABLESPACE "&TABLESPACE1." ;
/
Table dropped.
SQL> SQL> SQL> 2 3 4 5 6 7 alt 7: ) TABLESPACE "&TABLESPACE1."
neu 7: ) TABLESPACE "USERS"
Table created.
SQL>
回答by Enjy
Are you sure your table space name is :"&TABLESPACE1"?
您确定您的表空间名称是 :"&TABLESPACE1" 吗?
Try to test if your table space existwith :
尝试使用以下命令测试您的表空间是否存在:
select Tablespace_name from dba_tablespaces
where Tablespace_name = 'yourtablespacename';