简体   繁体   English

使用jdbc重命名sql中的列

[英]Renaming a column in sql using jdbc

I created a table (using NetBeans I went to Databases, into jdbc, into app and created a table). 我创建了一个表(使用NetBeans,我去了数据库,进入了jdbc,进入了应用程序并创建了一个表)。 I am 80% sure this is a SQL table but I could be wrong. 我80%肯定这是一个SQL表,但是我可能是错的。

I named one of my columns as secretQuestion but now I need to change it to securityQuestion. 我将其中一列命名为secretQuestion,但现在我需要将其更改为securityQuestion。

I looked online and found the following: 我在网上查看后发现:

ALTER table app.mytable CHANGE secretQuestion to securityQuestion;
ALTER table app.mytable RENAME secretQuestion to securityQuestion varchar (100);

neither CHANGE nor RENAME are recognized. CHANGE和RENAME均无法识别。

I am a slow-witted newbie so be very specific in your answer so that I can follow along! 我是一个机智的新手,所以在回答中要非常具体,以便我可以跟进!

I am using Derby! 我正在使用Derby!

See here . 这里

RENAME COLUMN statement 重命名COLUMN语句

Syntax 句法

RENAME COLUMN table-Name.simple-Column-Name TO simple-Column-Name

Examples 例子

To rename the manager column in table employee to supervisor, use the following syntax: 要将表employee中的manager列重命名为supervisor,请使用以下语法:

RENAME COLUMN EMPLOYEE.MANAGER TO SUPERVISOR

i have one syntax please remove 'to' keyword. 我有一种语法,请删除“ to”关键字。 it worked for me. 它为我工作。 Be sure about the table name and old column name 确保有关表名和旧列名

ALTER TABLE tablename CHANGE name newname DATATYPE;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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