문제

I have a mySQL table called test:

create table test(
    locationExpect varchar(120) NOT NULL;
);

I want to change the locationExpect column to:

create table test(
    locationExpect varchar(120);
);

How can it be done quickly?

도움이 되었습니까?

해결책

Do you mean altering the table after it has been created? If so you need to use alter table, in particular:

ALTER TABLE tablename MODIFY COLUMN new-column-definition

e.g.

ALTER TABLE test MODIFY COLUMN locationExpect VARCHAR(120);

다른 팁

Syntax to change column name in MySql:

alter table table_name change old_column_name new_column_name data_type(size);

Example:

alter table test change LowSal Low_Sal integer(4);

This should do it:

ALTER TABLE test MODIFY locationExpert VARCHAR(120) 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top