System/OS
2003.04.23 11:08
[sql] alter table 쿼리 예제
조회 수 12523 댓글 0
자주 안쓰니 까먹지ㅡㅡ;;
Table 수정 관련 쿼리 형식
ALTER TABLE 테이블명 ADD '컬럼명' '컬럼타입'; ALTER TABLE 테이블명 CHANGE '변경할 컬럼명' '새로운 컬럼명' '컬럼 타입'; ALTER TABLE 테이블명 MODIFY '컬럼명' '컬럼 타입';
## MSSQL 에서는.. ##
ms-sqlserver에서 table 또는 필드 속성변경은 alter문을 사용하여 합니다.
< 필드의 데이타타입 변경 >
alter table table명 alter column 필드명 datatype
ex) test table의 fld필드를 varchar -> int로 변경
alter table test alter column fld int
참고) 실제 입력 되어있는 자료중 int형식으로 변경할 수 없는 경우,
(''aaa''값과 같이)에는 sqlserver는 에러를 냅니다.
< table에 새로운 필드 추가 >
alter table table명 add 필드명 datatype
ex) test table의 fld1을 varchar 데이타타입 8자리로 추가하는 경우
alter table test add fld1 varchar(8)
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
202 | System/OS | [apache2] Redirect HTTP to HTTPS | hooni | 2022.02.03 | 863 |
201 | System/OS | [macos] How to Fix ‘You Shut Down Your Computer Because of a Problem’ | hooni | 2022.06.01 | 972 |
200 | System/OS | 개인적으로 쓰고 있는 bash_profile | hooni | 2015.01.16 | 994 |
199 | System/OS | [linux] The Ultimate Wget Download Guide With 15 Awesome Examples | hooni | 2020.05.26 | 998 |
198 | System/OS | 개인적으로 쓰고 있는 zshrc 파일 | hooni | 2022.02.25 | 1024 |
197 | System/OS | [mac] How to uninstall MySQL on Mac OS. | hooni | 2017.11.08 | 1050 |
196 | System/OS | [virtualbox] VirtualBox에 Ubuntu 설치하기 | hooni | 2019.11.22 | 1075 |
195 | System/OS | [펌] 마이크로서비스, 모노리포, SRE, ... 덮어놓고 구글 따라하면 안 되는 기술들 | hooni | 2020.10.15 | 1113 |
194 | System/OS | [mac] 패키지 매니저, MacPort | hooni | 2015.01.03 | 1131 |
193 | System/OS | 콘솔에서 패스워드 걸린 zip 압축하는 명령 | hooni | 2018.03.02 | 1137 |
192 | System/OS | [svn] Can't convert string from native encoding to 'UTF-8' 메시지가 나오는 경우 | hooni | 2014.12.18 | 1164 |
191 | System/OS | [mac] OS X 엘 캐피탄에서 Soudflower 사용하기 2 | hooni | 2016.10.03 | 1179 |