gpt4 book ai didi

sql - 更改 Oracle 表名

转载 作者:行者123 更新时间:2023-12-03 03:52:35 25 4
gpt4 key购买 nike

我正在尝试更改 Oracle 中的表名称。我首先运行此脚本来声明表

CREATE TABLE CUSTOMER
(
C_ID NUMBER(6,0),
C_LAST VARCHAR2(25),
C_FIRST varchar2(25),
C_MI char(1),
C_DOB DATE,
C_ADDRESS varchar2(100),
C_CITY varchar2(35),
C_STATE char(2),
C_ZIP varchar2(10),
C_DPHONE varchar2(12),
C_EPHONE varchar2(12),
C_USERID varchar2(20),
C_PASSWORD VARCHAR2(30),
CONSTRAINT CUSTOMER_PK PRIMARY KEY(C_ID)
);

CREATE TABLE ORDER_SOURCE
(
OS_ID NUMBER(6),
OS_DESC varchar2(255),
CONSTRAINT ORDER_SOURCE_PK PRIMARY KEY(OS_ID)
);

CREATE TABLE ORDERS
(
O_ID NUMBER(6),
O_DATE DATE,
O_METHPMT varchar2(25),
C_ID NUMBER(6),
OS_ID NUMBER(6),
CONSTRAINT ORDERS_PK PRIMARY KEY(O_ID),
CONSTRAINT ORDERS_CUSTOMER_FK FOREIGN KEY(C_ID) REFERENCES CUSTOMER(C_ID),
CONSTRAINT ORDERS_ORDER_SOURCE_FK FOREIGN KEY(OS_ID) REFERENCES ORDER_SOURCE(OS_ID)
);

它运行正确,然后我尝试运行

alter table ORDERS
rename to ORDER;

我收到此错误:

Error starting at line 1 in command: alter table ORDERS rename to ORDER Error report: SQL Error: ORA-00903: invalid table name 00903. 00000 - "invalid table name" *Cause:
*Action:

最佳答案

语法“RENAME TABLE tab_old TO tab_new”不正确。
正确语法:“RENAME tab_old TO tab_new”。
语句中不应出现“TABLE”一词。

关于sql - 更改 Oracle 表名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13292652/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com