>  기사  >  데이터 베이스  >  mysql에서 alter 명령어 사용에 대한 자세한 설명

mysql에서 alter 명령어 사용에 대한 자세한 설명

黄舟
黄舟원래의
2017-08-20 15:06:301824검색

이 글은 주로 2급 컴퓨터 시험의 MySQL 지식 포인트를 자세하게 소개하고, mysql에서 alter 명령의 사용법을 자세하게 소개합니다. 관심 있는 친구는 참고할 수 있습니다.

mysql의 alter 명령은 다음과 같습니다. 사용법, 테이블 구조를 편집하는 데 사용됩니다. 구체적인 내용은 다음과 같습니다

필드 유형 수정


mysql> alter table employee change depno depno int(5) not null;

색인 추가


mysql> alter table 表名 add index 索引名 (字段名1[,字段名2 …]);

예:


mysql> alter table employee add index emp_name (name);

기본 키워드 색인 추가


mysql> alter table 表名 add primary key (字段名);

Ex 넉넉함:


mysql> alter table employee add primary key(id);

고유 제한이 있는 인덱스


mysql> alter table 表名 add unique 索引名 (字段名);

예:


mysql> alter table employee add unique emp_name2(cardnumber);

테이블의 인덱스 보기


mysql> show index from 表名;

예:


mysql> show index from employee;

인덱스 삭제


mysql> alter table 表名 drop index 索引名;

예 :


mysql>alter table employee drop index emp_name;

테이블 수정: 필드 추가:


mysql> ALTER TABLE table_name ADD field_name field_type;

테이블 보기:


mysql> SELECT * FROM table_name;

원래 필드 이름 및 유형 수정:


mysql> ALTER TABLE table_name CHANGE old_field_name new_field_name field_type;

필드 삭제:


rreee

위 내용은 mysql에서 alter 명령어 사용에 대한 자세한 설명의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.