📄 altertable.asp
字号:
<%
if len(request("run")) > 0 then
sql = "alter table " & request("db") & "." & request("tb") & " " & request("action") & " "
if request("action") = "change" then
sql = sql & request("oldcolname") & " "
end if
sql = sql & request("field") & " " & request("field_type")
if len(request("LengthValues")) > 0 then
sql = sql & "(" & request("LengthValues") & ")"
end if
if len(request("field_null")) > 0 then
sql = sql & " NULL"
else
sql = sql & " NOT NULL"
end if
if len(request("field_default")) > 0 then
sql = sql & " DEFAULT '" & request("field_default") & "'"
END IF
if len(request("field_extra")) > 0 then
sql = sql & " " & request("field_extra")
end if
'Response.Write sql
'Response.End
Response.Redirect "runquery.asp?db=" & request("db") & "&tb=" & request("tb") & "&vQuery=" & server.URLEncode(sql)
end if
response.buffer = true
%>
<!--#include file="top.asp"-->
<TABLE WIDTH=750 bgcolor=#E7F1EC cellspacing=1 cellpadding=0 border=0>
<TR>
<TD width=200 valign=top><!--#include file="left.asp"--></TD>
<TD width=550 valign=top>
<TABLE WIDTH=100% cellpadding=5 cellspacing=0>
<TR>
<TD bgcolor="#339999" align=center class=celltitle><%=Request("db")%> -- <%=request("tb")%></TD>
</TR>
<TR>
<TD>
<TABLE cellpadding=2 cellspacing=1 border=0 style="border:solid black 1pt;">
<FORM ACTION="altertable.asp?db=<%=request("db")%>&tb=<%=request("tb")%>&col=<%=request("col")%>&run=y&action=<%=request("action")%>" METHOD=post>
<TR>
<TD bgcolor=#339999 class=cellsmalltitle align=center colspan=7><%if request("action") ="change" then%>Alter<%else%>Add<%end if%> Column <%if action="change" then%>-- <%=request("col")%><%end if%></TD>
</TR>
<TR>
<TD class=cellsmallcontent><B>Field</B></TD>
<TD class=cellsmallcontent><B>Type</B></TD>
<TD class=cellsmallcontent><B>Length/Values</B></TD>
<TD class=cellsmallcontent><B>Attributes</B></TD>
<TD class=cellsmallcontent><B>Null</B></TD>
<TD class=cellsmallcontent><B>Default</B></TD>
<TD class=cellsmallcontent><B>Extra</B></TD>
</TR>
<%
if request("action") = "change" then
set rsAlter = server.CreateObject("ADODB.Recordset")
rsAlter.CursorLocation = 3
rsAlter.Open "show columns from " & request("db") & "." & request("tb"), dsn, 2, 3
rsAlter.Filter = "field = '" & request("col") & "'"
action = "change"
else
action = "new"
end if
%>
<TR>
<TD><INPUT TYPE=TEXT NAME=field style="width:75px;" value='<%if action="change" then : Response.write rsAlter("field") : end if%>'><INPUT TYPE=HIDDEN NAME=OldColName value='<%if action="change" then : Response.write rsAlter("field") : end if%>'></TD>
<TD>
<%
if action="change" then
if instr(rsAlter("type"), "(") then
thisTypeO = replace(replace(rsAlter("type"), "(", " "), ")", " ")
thisAry = split(thisTypeO, " ", "2")
for each x in thisAry
j = j + 1
if isNumeric(x) then
thisLength = x
elseif not IsNumeric(x) and x <> " " then
thisType = x
end if
next
else
thisType = rsAlter("type")
end if
end if
%>
<select name="field_type">
<option value="TINYINT"<%if uCase(thisType) = "TINYINT" then%> Selected<%end if%>>TINYINT</option>
<option value="SMALLINT"<%if uCase(thisType) = "SMALLINT" then%> Selected<%end if%>>SMALLINT</option>
<option value="MEDIUMINT"<%if uCase(thisType) = "MEDIUMINT" then%> Selected<%end if%>>MEDIUMINT</option>
<option value="INT"<%if uCase(thisType) = "INT" then%> Selected<%end if%>>INT</option>
<option value="BIGINT"<%if uCase(thisType) = "BIGINT" then%> Selected<%end if%>>BIGINT</option>
<option value="FLOAT"<%if uCase(thisType) = "FLOAT" then%> Selected<%end if%>>FLOAT</option>
<option value="DOUBLE"<%if uCase(thisType) = "DOUBLE" then%> Selected<%end if%>>DOUBLE</option>
<option value="DECIMAL"<%if uCase(thisType) = "DECIMAL" then%> Selected<%end if%>>DECIMAL</option>
<option value="DATE"<%if uCase(thisType) = "DATE" then%> Selected<%end if%>>DATE</option>
<option value="DATETIME"<%if uCase(thisType) = "DATETIME" then%> Selected<%end if%>>DATETIME</option>
<option value="TIMESTAMP"<%if uCase(thisType) = "TIMESTAMP" then%> Selected<%end if%>>TIMESTAMP</option>
<option value="TIME"<%if uCase(thisType) = "TIME" then%> Selected<%end if%>>TIME</option>
<option value="YEAR"<%if uCase(thisType) = "YEAR" then%> Selected<%end if%>>YEAR</option>
<option value="CHAR"<%if uCase(thisType) = "CHAR" then%> Selected<%end if%>>CHAR</option>
<option value="VARCHAR"<%if uCase(thisType) = "VARCHAR" then%> Selected<%end if%>>VARCHAR</option>
<option value="TINYBLOB"<%if uCase(thisType) = "TINYBLOB" then%> Selected<%end if%>>TINYBLOB</option>
<option value="TINYTEXT"<%if uCase(thisType) = "TINYTEXT" then%> Selected<%end if%>>TINYTEXT</option>
<option value="TEXT"<%if uCase(thisType) = "TEXT" then%> Selected<%end if%>>TEXT</option>
<option value="BLOB"<%if uCase(thisType) = "BLOB" then%> Selected<%end if%>>BLOB</option>
<option value="MEDIUMBLOB"<%if uCase(thisType) = "MEDIUMBLOB" then%> Selected<%end if%>>MEDIUMBLOB</option>
<option value="MEDIUMTEXT"<%if uCase(thisType) = "MEDIUMTEXT" then%> Selected<%end if%>>MEDIUMTEXT</option>
<option value="LONGBLOB"<%if uCase(thisType) = "LONGBLOB" then%> Selected<%end if%>>LONGBLOB</option>
<option value="LONGTEXT"<%if uCase(thisType) = "LONGTEXT" then%> Selected<%end if%>>LONGTEXT</option>
<option value="ENUM"<%if uCase(thisType) = "ENUM" then%> Selected<%end if%>>ENUM</option>
<option value="SET"<%if uCase(thisType) = "SET" then%> Selected<%end if%>>SET</option>
</select>
</TD>
<TD><INPUT TYPE=TEXT NAME=LengthValues style="width:75px;" value='<%if action="change" then : Response.write thisLength : end if%>'></TD>
<TD>
<select name="field_attribute">
<option value="" selected="selected"></option>
<option value="BINARY">BINARY</option>
<option value="UNSIGNED">UNSIGNED</option>
<option value="UNSIGNED ZEROFILL">UNSIGNED ZEROFILL</option>
</select>
</TD>
<TD>
<select name="field_null">
<option value=""<%if action="change" then
if rsAlter("null") <> "YES" then%> Selected<%end if
end if%>>Not Null</option>
<option value="YES"<%if action="change" then
if rsAlter("null") <> "YES" then%> Selected<%end if
end if%>>Null</option>
</select>
</TD>
<TD><INPUT TYPE=TEXT NAME=field_default style="width:75px;" value='<%if action="change" then : Response.write rsAlter("default") : end if%>'></TD>
<TD>
<select name="field_extra">
<option value=""<%if action="change" then
if lcase(rsAlter("extra")) <> "auto_increment" then%> Selected<%end if
end if%>></option>
<option value="AUTO_INCREMENT"<%if action="change" then
if lcase(rsAlter("extra")) = "auto_increment" then%> Selected<%end if
end if%>>auto_increment</option>
</select>
</TD>
</TR>
<TR>
<TD colspan=7>
<INPUT TYPE=SUBMIT VALUE="<%if action="change" then%>Make Changes<%else%>Add Column<%end if%>"> <INPUT TYPE=BUtton Value="Cancel" onclick="window.history.go(-1);">
</TD>
</TR>
</FORM>
</TABLE>
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
<!--#include file="bottom.asp"-->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -