반응형

TABLE COLUMN 속성 변경


1. 제약조건이 없는 테이블 컬럼 변경 SQL 쿼리


ALTER TABLE [table name] ALTER COLUMN [column name] [date type] [NULL | NOT NULL]


2. 속성을 변경할 테이블 컬럼에 제약조건이 걸려 있는 경우

1번 쿼리를 실행하면 


Msg 5074, Level 16, State 1, Line 2
개체 'DF_SampleTable_Name'은(는) 열 'Name'에 종속되어 있습니다.
Msg 4922, Level 16, State 9, Line 2
하나 이상의 개체가 이 열에 액세스하므로 ALTER TABLE ALTER COLUMN Name이(가) 실패했습니다


위와 같은 에러메세지가 발생한다.

위 에러 메세지는 속성을 변경할 해당 컬럼에 "Primary key"가 설정되어 있거나 "기본값 또는 바인딩" 또는 "그 외 제약 조건"이 설정되어 있어서 발생하는 경우이다.


위 에러 메세지를 해결하기 위해 해당 컬럼에 적용된 제약조건을 제거하고 컬럼 속성을 변경 또는 삭제하면 된다.


먼제 삭제할 제약 조건의 이름을 확인하기 위해 Table에 걸린 제약 조건 확인 SQL 쿼리를 실행한다.


EXEC sp_helpindex [table name]


위 쿼리로 Table에 설정된 Key를 확인할 수 있다.


기본값 또는 바인딩 제약 조건명은 컬럼 변경 SQL문을 실행할 때 발생하는 오류 메세지에서 확인 할 수 있다. 위 오류 메세지에서는 "DF_SampleTable_Name" 이 Name컬럼에 걸린 기본값 또는 바인딩을 설정한 제약 조건의 이름이다.


제약 조건 삭제 SQL 쿼리


ALTER TABLE [table name] DROP CONSTRAINT [제약 조건 이름]


위 쿼리로 제약조건을 제거 할 수 있다.


제약 조건을 제거하면 1번에서 소개한 쿼리문을 실행하여 테이블 컬럼 속성을 변경할 수 있다.


* 단 컬럼 내 데이터가 변경할 데이터 타입으로 형식이 아니면 컬럼 데이터 타입 속성 변경이 실패한다.


반응형

'Database > SQL Server' 카테고리의 다른 글

B-TREE 구조  (0) 2018.11.15
SQL 실행계획  (0) 2018.11.12
Database 내 모든 테이블 정보 확인  (0) 2018.06.14
동적 쿼리와 정적 쿼리  (0) 2018.05.23
Stored Procedure(저장 프로시저)  (0) 2018.05.23
반응형

Database 살펴 볼 때 내부 테이블들의 모든 정보를 알고 싶은 경우가 있다.


각 테이블을 조회하는 노가다 성 작업으로 해결할 수 도 있지만 테이블의 수가 많을 경우는 많은 시간이 소비된다.


다행히 한번에 모든 테이블 정보를 볼 수 있는 sql 쿼리문이 있다.


SELECT * FROM INFORMATION_SCHEMA.COLUMNS ORDER BY TABLE_NAME


위 쿼리문을 동작하면 Database 내 모든 테이블 컬럼 정보를 확인할 수 있다.


*Microsoft SQL Server Management Studio에서 실행.

반응형

'Database > SQL Server' 카테고리의 다른 글

SQL 실행계획  (0) 2018.11.12
[MSSQL] Table Column 속성 변경  (0) 2018.06.25
동적 쿼리와 정적 쿼리  (0) 2018.05.23
Stored Procedure(저장 프로시저)  (0) 2018.05.23
MS-SQL SP_EXECUTESQL  (0) 2018.05.23
반응형

Modals

data-toggle="modal" - Triggers click to open a modal dialog referenced by data-target="element"data-target="target-element" - The element that the modal should open (can be #id or .class)
data-dismiss="modal" - Triggers close of the modal on click


Dropdowns

data-toggle="dropdown" - Triggers click to open a drop-down
data-target="#" - Only exists to help when use the dropdown on link to prevent url change


ScrollSpy

data-spy="scroll" - Triggers the SpyScroll on the element (usually goes to <body>
data-target="target-element" - The element that the scroll-spy should by applied to
data-offset="X" - X represents the number of pixels from top when calculating position of scroll


Togglable tabs

data-toggle="tab" - Triggers click to open the relevant tab referenced by data-target="element"
data-toggle="pill" - Same as tab but for pill-styling
data-target="target-element" - The element that the modal should open (can be #id or .class)


Tooltips

data-toggle="tooltip" - Triggers adding a tooltip to the element

data-animation
data-container
data-delay
data-html
data-placement
data-selector
data-template
data-title
data-trigger
data-viewport


Popovers

data-toggle="popover" - Triggers click to open a popover

data-animation
data-container
data-content
data-delay
data-html
data-placement
data-selector
data-template
data-title
data-trigger
data-viewport


Alert messages

data-dismiss="alert" - Triggers click to close the alert box created by bootstrap


Buttons

data-loading-text="Loading..." - Show a text while loading (note that it's deprecated)
data-toggle="button" - note the singular Makes a button single toggle-button data-toggle="buttons" - note the plural Makes a group of buttons a toggle-buttons
data-complete-text="Finished" - Text to change on button when the method complete is called


Collapse

data-toggle="collapse" - Triggers click to collapse the referenced element
data-target="element" - The referenced element
data-parent="element" - The parent element, used for accordion-style collapsing


Carousel

data-ride="carousel" - Triggers a slide-show (carousel) on the container
data-target="element" - The referenced carousel element that this element is part of
data-slide-to="X" - X is the number of the next slide
data-slide="prev|next" - Triggers click to toggle the carousel to the prev|next slide
data-interval="X" - The amount of time to delay between automatically cycling an item
data-pause="hover" - Pause the cycling on mouse over
data-wrap="true" - Whether the carousel should cycle continuously or have hard stops
data-keyboard="true" - Whether the carousel should react to keyboard events


Affix

data-spy="affix" - Triggers affix (emulating the sticky positioning effect)
data-offset-top="X" - Number of pixels to offset the element from top
data-offset-bottom="X" - Number of pixels to offset the element from bottom

*참고 사이트 : https://stackoverflow.com/questions/38336625/how-many-data-attributes-there-are-in-bootstrap-what-they-do-and-what-are-the-p

https://getbootstrap.com/docs/3.3/javascript/

반응형

+ Recent posts