컬럼 추가 삭제

2012. 9. 10. 18:49

CREATE TABLE

col_name DataType DataSize NOT NULL PK
  Constraint FOREIGN KEY
REFERENCES ( )
||




<style>



#bodyBG {

 background: #8c92ac;

 background: -moz-linear-gradient(bottom, #8c92ac, #fff) no-repeat;

 background: -o-linear-gradient(bottom, rgb(140,146,172), rgb(255,255,255)) no-repeat;

 background: -webkit-gradient(linear, center bottom, center top, from(#8c92ac), to(#fff)) no-repeat;

}

</style>



<script type="text/javascript">

$(function(){

var strCr = "";

var strRef = "";

var strRefCol = "";

$("#helperOK").live("click",function(){

var result="";

var primarySQL="";

var sqlInfo=$("#dialog-createTable tr");

//$("#dialog-createTable tr").each()

result +="CREATE TABLE "+sqlInfo.eq(0).find("#table_name").val()+"\n(\n";

for(var i=2;i<(sqlInfo.size()-3);i++){

if(sqlInfo.eq(i).find(".col_Name").val()!=""){

result +=sqlInfo.eq(i).find(".col_Name").val()+" ";

result +=sqlInfo.eq(i).find("#col_Type option:selected").text();

result +=" ("+sqlInfo.eq(i).find(".col_Size").val()+") ";

/* alert(sqlInfo.eq(i).find("#col_check").attr('checked'));

return; */

if(sqlInfo.eq(i).find("#col_check").attr('checked')){

result += " NOT NULL ,\n";

}else {

result += " ,\n";

}

if(sqlInfo.eq(i).find(".col_Primary").attr('checked')){

primarySQL ="PRIMARY KEY ("+sqlInfo.eq(i).find(".col_Name").val()+")";

}

}else {

alert("모두 채우셔야 합니다.");

return;

}

}

result +=primarySQL;

if($(".create_constraint").val()!="####_PK"){

result +=",\n CONSTRAINT "+$(".create_constraint").val();

result +=" "+$("#create_foreign option:selected").text();

result +=" REFERENCES "+$("#create_reference option:selected").text()+" ("+$("#create_reference_table option:selected").text()+")";

}else{

result +="\n"

}

result+=")";

// 이런식으로 저장 해보자. 부모장에 돌려 주기. 

window.opener.document.getElementById("sqlInput").value=result;


window.open("about:blank","_self").close();

});

$("#helperCancel").live("click",function(){

// self.closed();   <-- 일부 브라우저 에서 작동 안한다 . crom x

                        alert("닫기는 브라우저 를 전체로 닫기 때문에 막아 놓았습니다. ");

                        return;

window.open("about:blank","_self").close();

});

$("#create_foreign").live("click", function() {

var str="";

var sqlInfo=$("#dialog-createTable tr");

for(var i=2;i<(sqlInfo.size()-4);i++){

str +="<option>"+sqlInfo.eq(i).find(".col_Name").val()+"</option>";

}

if(str!=strCr){

strCr=str;

$("#create_foreign").html(str);

}

});


$("#btncolAdd").live("click",function(){

var innerTR_Col="";

innerTR_Col+="<tr>                                                                      ";

innerTR_Col+=" <td align='center'><input type='text' size='15'                       ";

innerTR_Col+=" class='col_Name' title='컬럽 이름' /></td>                           ";

innerTR_Col+=" <td align='center'><select title='데이터 타입' id='col_Type'>              ";

innerTR_Col+=" <option>VARCHAR2</option>                                     ";

innerTR_Col+=" <option>NUMBER</option>                                       ";

innerTR_Col+=" <option>CHAR</option>                                         ";

innerTR_Col+=" <option>DATE</option>                                     ";

innerTR_Col+=" <option>TIMESTAMP</option>                                    ";

innerTR_Col+=" <option>DEC</option>                                          ";

innerTR_Col+=" <option>BOLB</option>                                         ";

innerTR_Col+=" <option></option>                                             ";

innerTR_Col+=" </select></td>                                                        ";

innerTR_Col+=" <td align='center'><input type='text' size='3'                       ";

innerTR_Col+=" class='col_Size' value='10' title='데이터 사이즈' maxlength='3' />     ";

innerTR_Col+=" </td>                                                                 ";

innerTR_Col+=" <TD align='center'><input type='checkbox' id='col_check'            ";

innerTR_Col+=" title='NULL 허용 여부'  /></TD>                      ";

innerTR_Col+=" <td align='center'><input name='primary' type='radio'                 ";

innerTR_Col+=" class='col_Primary' title='기본키'/></td>         ";

innerTR_Col+="</tr>                                                                     ";

$("#btncolAddSpan").append(innerTR_Col);

});


$("#create_reference").live("click", function() {

//

$.ajax({

"url" : "tableData.do",

"type" : "post",

"dataType" : "json",

"data" : {

"dataType" : "init"

},

"success" : function(data) {

var str ="";

$.each(

data,

function(i, v) {

str +="<option>"+v.TableName+"</option>";

});

if (str != strRef) {

strRef = str;

$("#create_reference").html(str);

}


// 테이블 가져 왔는지 확인

//alert(tableListArray.toString());

},

"error" : function(info, xhr) {

if (info.readyState == '4') {

alert('문제가 발생했습니다.\n상태코드 : ' + info.status + '\n\n'

+ info.responseText);

} else {

alert('문제가 발생했습니다.\n잠시후 다시 시도해 주세요.\n 상태코드 : '

+ info.status);

}

}

});

});

$("#btncolMinus").live("click",function(){

var sqlInfo=$("#dialog-createTable tr");

var maxSize=sqlInfo.size();

if(maxSize<=6){

return;

}

$("#dialog-createTable tr").eq(maxSize-4).remove();

});

$("#create_reference_table")

.live(

"click",

function() {

var x = document

.getElementById("create_reference");

//alert(x.options[x.selectedIndex].value);

var ref_selected = x.options[x.selectedIndex].value;

var str = "";

$

.ajax({

"url" : "tableData.do",

"type" : "post",

"dataType" : "json",

"data" : {

"dataType" : "Reference_col",

"selectedItem" : ref_selected

},

"success" : function(data) {

//alert("가져온 데이터 입니다 . " + data);

$.each(data, function(i, v) {

str += "<option>"

+ v.column

+ "</option>";

});

if (str != strRefCol) {

strRefCol = str;

$("#create_reference_table")

.html(str);

}


},

"error" : function(info, xhr) {

if (info.readyState == '4') {

alert('문제가 발생했습니다.\n상태코드 : '

+ info.status

+ '\n\n'

+ info.responseText);

} else {

alert('문제가 발생했습니다.\n잠시후 다시 시도해 주세요.\n 상태코드 : '

+ info.status);

}

}

});


});

});

</script>

<div id="bodyBG">

<div id="dialog-createTable" style="width: 500px; height: 370px; ">

<form name="createForm">

<table style="width: 500px; height: 250px; overflow: auto;">

<tbody><tr>

<td colspan="3">

<h3>

CREATE TABLE <input id="table_name" name="table_name" type="text" size="15" class="create_Name" title="테이블 이름">

</h3>

</td>

<td>

</td>

<td colspan="2">

<input id="btncolAdd" type="button" value="+" title="컬럼추가">

<input id="btncolMinus" type="button" value="-" title="컬럼 삭제">

</td>

</tr>

<tr>

<td width="162" align="center">col_name</td>

<td width="153" align="center">DataType</td>

<td width="69" align="center">DataSize</td>

<td width="72" align="center">NOT NULL</td>

<td width="69" align="center">PK</td>

</tr>

<tr>

<td align="center"><input type="text" size="15" class="col_Name" title="컬럽 이름"></td>

<td align="center"><select title="데이터 타입" id="col_Type">

<option>NUMBER</option>

<option>VARCHAR2</option>

<option>CHAR</option>

<option>DATE</option>

<option>TIMESTAMP</option>

<option>DEC</option>

<option>BOLB</option>

<option></option>

</select></td>

<td align="center"><input type="text" size="3" class="col_Size" value="10" title="데이터 사이즈" maxlength="3">

</td>

<td align="center"><input type="checkbox" id="col_check" title="NULL 허용 여부" checked="checked"></td>

<td align="center"><input name="primary" type="radio" class="col_Primary" title="기본키" checked="checked"></td>

</tr>

</tbody><tbody id="btncolAddSpan" style="overflow: auto;">

</tbody>

<tbody><tr>

<td colspan="5"></td>

</tr>

<tr>

<td colspan="5">

&nbsp;&nbsp;Constraint <input type="text" size="6" class="create_constraint" title="제약명을 입력해주세요." value="####_PK">FOREIGN KEY <select id="create_foreign">

<option>클 릭</option>

</select> 

</td>

</tr>

<tr>

<td>

</td>

<td colspan="5" style="text-align: left;">

REFERENCES <select id="create_reference">

<option>클 릭</option>

</select> ( <select id="create_reference_table">

<option>클 릭</option>

</select> )

</td>

</tr>


<tr style="height: 80px">

<td colspan="3">

</td>

<td colspan="2">

<input id="helperOK" type="button" value="O K">||<input id="helperCancel" type="button" value="Cancel">

</td>

</tr>

</tbody></table>

</form>


</div>

</div>

'J-Query' 카테고리의 다른 글

jQuery 라이브러리 사용 방법  (1) 2012.11.15
sliding  (0) 2012.11.15
jQuey 1.8 이 정식 릴리즈 되었습니다.  (0) 2012.08.24
jQuery.slide()  (0) 2012.07.10
body CSS 그라데이션 흰색 - > 블랙  (0) 2012.06.22
Posted by 사라링
BLOG main image
.. by 사라링

카테고리

사라링님의 노트 (301)
JSP (31)
J-Query (41)
JAVA (24)
VM-WARE (0)
디자인패턴 (1)
스크랩 (0)
스트러츠 (3)
안드로이드 (11)
오라클 (45)
우분투-오라클 (1)
이클립스메뉴얼 (6)
스프링3.0 (23)
자바스크립트 (10)
HTML5.0 (17)
정보처리기사 (1)
기타(컴퓨터 관련) (1)
문제점 해결 (3)
프로젝트 (2)
AJAX (4)
하이버네이트 (3)
트러스트폼 (11)
Jeus (2)
재무관리(회계) (5)
정규식 (5)
아이바티스 (8)
취미 (2)
소프트웨어 보안 관련모음 (0)
정보보안기사 (6)
C언어 베이직 및 프로그램 (3)
보안 관련 용어 정리 (2)
넥사크로 (6)
Total :
Today : Yesterday :