简体   繁体   中英

SQL alter table works in MySQL but not in Oracle

I have created a table users

create table users (
id int,
name varchar(40)
);

Now i want a default value for name

This query works in MYSQL but not in Oracle database 11g XE

alter table users alter name set default 'user';

Can anyone explain why ?

The syntax for adding a default to an existing column is different in Oracle, viz:

alter table users
modify (name default 'user');

SqlFiddle here

我认为正确的查询将是这样的:

ALTER TABLE users MODIFY name VARCHAR(40) NOT NULL DEFAULT 'user';

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