[Mydatabasepilot-cvs] MyDatabasePilot/Query alterTable.cfm,1.7,1.8
Status: Alpha
Brought to you by:
nanoface
From: <nan...@us...> - 2003-06-16 14:35:47
|
Update of /cvsroot/mydatabasepilot/MyDatabasePilot/Query In directory sc8-pr-cvs1:/tmp/cvs-serv29780/Query Modified Files: alterTable.cfm Log Message: Functionality Added: [ 755353 ] Added BINARY to VARCHAR,CHAR field Types Index: alterTable.cfm =================================================================== RCS file: /cvsroot/mydatabasepilot/MyDatabasePilot/Query/alterTable.cfm,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** alterTable.cfm 16 Jun 2003 04:31:48 -0000 1.7 --- alterTable.cfm 16 Jun 2003 14:35:44 -0000 1.8 *************** *** 1,304 **** ! <!---******************************************************************************************* ! * Copyright: MyDatabase Pilot is distributed under the terms of the GNU GPL license * ! * Template: Query/alterTable.cfm (Custom Tag) * ! * Purpose: - Executes and/or displays an ALTER TABLE command * ! * - In Start Mode, the alter table strings are generated and sent back to * ! * caller if requested * ! * - In End Mode, the Query is executed * ! * Inputs Required: - table String * ! * - execute Boolean * ! * - alterSpec Array of Structures * ! * Inputs Optional: - dataSource String * ! * - userName String * ! * - password String * ! * - sqlOutputType (RAW|HTML|BOTH) * ! * Outputs: - rawOutput String * ! * - htmlOutput String * ! * Other Requirements- This Custom Tag requires an end tag * ! ********************************************************************************************---> ! ! <!---||| Determine which execution mode this custom tag is in |||---> ! <cfswitch expression="#ThisTag.ExecutionMode#"> ! <!---||| If in start mode ... |||---> ! <cfcase value="start"> ! <!----------------------> ! <!--- Error Checking ---> ! <!----------------------> ! <!---||| Check for existence of Required Attributes |||---> ! <!--- This needs to be developed ---> ! ! <!---||| Check for proper data types, to ensure SQL syntax is correct |||---> ! <!--- This needs to be developed ---> ! ! <!--------------------------------------------> ! <!--- Generate ALTER TABLE Command Strings ---> ! <!--------------------------------------------> ! <!---||| Initialize Internal Variables |||---> ! <cfset rawSQL = "ALTER TABLE"> ! <cfset htmlSQL = "<span class=""KeyWord"">ALTER TABLE</span>"> ! ! <!---||| Table Name |||---> ! <cfset rawSQL = "#rawSQL# #ATTRIBUTES.table#"> ! <cfset htmlSQL = "#htmlSQL# <span class=""String"">#ATTRIBUTES.table#</span>"> ! ! <!---||| Alter Specifications |||---> ! <!--- Process each Alter Specification ----> ! <cfloop from="1" to="#arrayLen(ATTRIBUTES.alterSpec)#" index="i"> ! <!--- If this is not the first alter specification add a comma to the last alterSpec ---> ! <cfif i GT 1> ! <cfset rawSQL = "#rawSQL#,"> ! <cfset htmlSQL = "#htmlSQL#,"> ! </cfif> ! ! <!--- Determine the alterSpec format ---> ! <cfswitch expression="#ATTRIBUTES.alterSpec[i].format#"> ! <cfcase value="ADD COLUMN"> ! <!--- ADD COLUMN KeyWord ---> ! <cfset rawSQL = "#rawSQL# ADD COLUMN"> ! <cfset htmlSQL = "#htmlSQL#<br /><span class=""KeyWord"">ADD COLUMN</span>"> ! ! <!--- Column Name ---> ! <cfif ATTRIBUTES.alterSpec[i].colName IS ""> ! <cfset rawSQL = "#rawSQL# NameNotSpecified_#i#"> ! <cfset htmlSQL = "#htmlSQL# <span class=""Missing"">NameNotSpecified_#i#</span>"> ! <cfelse> ! <cfset rawSQL = "#rawSQL# #ATTRIBUTES.alterSpec[i].colName#"> ! <cfset htmlSQL = "#htmlSQL# <span class=""String"">#ATTRIBUTES.alterSpec[i].colName#</span>"> ! </cfif> ! ! <!--- Column Type ---> ! <cfif ATTRIBUTES.alterSpec[i].colType IS "" OR ATTRIBUTES.alterSpec[i].colType IS "Empty"> ! <cfset rawSQL = "#rawSQL# DataTypeNotSpecified_#i#"> ! <cfset htmlSQL = "#htmlSQL# <span class=""Missing"">DataTypeNotSpecified_#i#</span>"> ! <cfelse> ! <cfset rawSQL = "#rawSQL# #ATTRIBUTES.alterSpec[i].colType#"> ! <cfset htmlSQL = "#htmlSQL# <span class=""KeyWord"">#ATTRIBUTES.alterSpec[i].colType#</span>"> ! <!--- Type Options ---> ! <cfswitch expression="#ATTRIBUTES.alterSpec[i].colType#"> ! <cfcase value="VARCHAR,CHAR"> ! <!--- Add Length to Output Strings ---> ! <cfif ATTRIBUTES.alterSpec[i].length IS ""> ! <cfset rawSQL = "#rawSQL#(LengthNotSpecified_#i#)"> ! <cfset htmlSQL = "#htmlSQL#(<span class=""Missing"">LengthNotSpecified_#i#</span>)"> ! <cfelse> ! <cfset rawSQL = "#rawSQL#(#ATTRIBUTES.alterSpec[i].length#)"> ! <cfset htmlSQL = "#htmlSQL#(<span class=""Number"">#ATTRIBUTES.alterSpec[i].length#</span>)"> ! </cfif> ! <!--- ! CHAR(length) [BINARY] ! VARCHAR(length) [BINARY] ! ---> ! </cfcase> ! <cfcase value="TINYBLOB,BLOB,MEDIUMBLOB,LONGBLOB,TINYTEXT,TEXT,MEDIUMTEXT,LONGTEXT"> ! <!--- ! TINYBLOB ! BLOB ! MEDIUMBLOB ! LONGBLOB ! TINYTEXT ! TEXT ! MEDIUMTEXT ! LONGTEXT ! ---> ! </cfcase> ! <cfcase value="ENUM,SET"> ! <!--- ! ENUM(value1,value2,value3,...) ! SET(value1,value2,value3,...)</cfcase> ! ---> ! </cfcase> ! <cfcase value="TINYINT,SMALLINT,MEDIUMINT,INT,INTEGER,BIGINT"> ! <!--- Add Length to Output Strings if Specified ---> ! <cfif ATTRIBUTES.alterSpec[i].length IS NOT ""> ! <cfset rawSQL = "#rawSQL#(#ATTRIBUTES.alterSpec[i].length#)"> ! <cfset htmlSQL = "#htmlSQL#(<span class=""Number"">#ATTRIBUTES.alterSpec[i].length#</span>)"> ! </cfif> ! <!--- ! TINYINT[(length)] [UNSIGNED] [ZEROFILL] ! SMALLINT[(length)] [UNSIGNED] [ZEROFILL] ! MEDIUMINT[(length)] [UNSIGNED] [ZEROFILL] ! INT[(length)] [UNSIGNED] [ZEROFILL] ! INTEGER[(length)] [UNSIGNED] [ZEROFILL] ! BIGINT[(length)] [UNSIGNED] [ZEROFILL] ! ---> ! </cfcase> ! <cfcase value="REAL,FLOAT,DOUBLE"> ! <!--- Add Length and Decimals to Output Strings if Specified ---> ! <cfif ATTRIBUTES.alterSpec[i].length IS NOT ""> ! <cfset rawSQL = "#rawSQL#(#ATTRIBUTES.alterSpec[i].length#,#ATTRIBUTES.alterSpec[i].numberOfDecimals#)"> ! <cfset htmlSQL = "#htmlSQL#(<span class=""Number"">#ATTRIBUTES.alterSpec[i].length#</span>,<span class=""Number"">#ATTRIBUTES.alterSpec[i].numberOfDecimals#</span>)"> ! </cfif> ! <!--- ! REAL[(length,decimals)] [UNSIGNED] [ZEROFILL] ! DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL] ! FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL] ! ---> ! </cfcase> ! <cfcase value="DECIMAL,NUMERIC"> ! <!--- Add Length to Output Strings ---> ! <cfif ATTRIBUTES.alterSpec[i].length IS "" AND ATTRIBUTES.alterSpec[i].numberOfDecimals IS ""> ! <cfset rawSQL = "#rawSQL#(LengthNotSpecified_#i#,DecimalsNotSpecified_#i#)"> ! <cfset htmlSQL = "#htmlSQL#(<span class=""Missing"">LengthNotSpecified_#i#</span>,<span class=""Missing"">DecimalsNotSpecified_#i#</span>)"> ! <cfelseif ATTRIBUTES.alterSpec[i].length IS ""> ! <cfset rawSQL = "#rawSQL#(LengthNotSpecified_#i#,#ATTRIBUTES.alterSpec[i].numberOfDecimals#)"> ! <cfset htmlSQL = "#htmlSQL#(<span class=""Missing"">LengthNotSpecified_#i#</span>,<span class=""Number"">#ATTRIBUTES.alterSpec[i].numberOfDecimals#</span>)"> ! <cfelseif ATTRIBUTES.alterSpec[i].numberOfDecimals IS ""> ! <cfset rawSQL = "#rawSQL#(#ATTRIBUTES.alterSpec[i].length#,DecimalsNotSpecified_#i#)"> ! <cfset htmlSQL = "#htmlSQL#(<span class=""Number"">#ATTRIBUTES.alterSpec[i].length#</span>,<span class=""Missing"">DecimalsNotSpecified_#i#</span>)"> ! <cfelse> ! <cfset rawSQL = "#rawSQL#(#ATTRIBUTES.alterSpec[i].length#,#ATTRIBUTES.alterSpec[i].numberOfDecimals#)"> ! <cfset htmlSQL = "#htmlSQL#(<span class=""Number"">#ATTRIBUTES.alterSpec[i].length#</span>,<span class=""Number"">#ATTRIBUTES.alterSpec[i].numberOfDecimals#</span>)"> ! </cfif> ! ! <!--- ! DECIMAL(length,decimals) [UNSIGNED] [ZEROFILL] ! NUMERIC(length,decimals) [UNSIGNED] [ZEROFILL] ! ---> ! </cfcase> ! <cfcase value="DATE,TIME,DATETIME,YEAR,TIMESTAMP"> ! <!--- ! DATE ! TIME ! TIMESTAMP ! DATETIME ! ---> ! </cfcase> ! </cfswitch> ! </cfif> ! </cfcase> ! <!--- ToDo Cases: ---> ! <cfcase value="ADD INDEX"></cfcase> ! <cfcase value="ADD PRIMARY KEY"></cfcase> ! <cfcase value="ADD UNIQUE"></cfcase> ! <cfcase value="ADD FULLTEXT"></cfcase> ! <cfcase value="ADD FOREIGN KEY"></cfcase> ! <cfcase value="ALTER COLUMN"></cfcase> ! <cfcase value="CHANGE COLUMN"></cfcase> ! <cfcase value="MODIFY COLUMN"></cfcase> ! <cfcase value="DROP COLUMN"></cfcase> ! <cfcase value="DROP PRIMARY KEY"></cfcase> ! <cfcase value="DROP INDEX"></cfcase> ! <cfcase value="DISABLE KEYS"></cfcase> ! <cfcase value="ENABLE KEYS"></cfcase> ! <cfcase value="RENAME TO"></cfcase> ! <cfcase value="ORDER BY"></cfcase> ! <cfcase value="table_options"></cfcase> ! </cfswitch> ! </cfloop> ! ! <!---||| Terminate SQL Statement with Semicolon |||---> ! <cfset rawSQL = "#rawSQL#;"> ! <cfset htmlSQL = "#htmlSQL#;"> ! </cfcase> ! ! <!---||| If in end mode ... |||---> ! <cfcase value="end"> ! <!------------------> ! <!--- Output SQL ---> ! <!------------------> ! <!---||| If Output was requested... |||---> ! <cfif IsDefined("ATTRIBUTES.sqlOutputType")> ! <!---||| Return RAW SQL if Requested |||---> ! <cfif ATTRIBUTES.sqlOutputType IS "RAW" OR ATTRIBUTES.sqlOutputType IS "BOTH"> ! <cfset "CALLER.#ATTRIBUTES.rawOutput#" = rawSQL> ! </cfif> ! ! <!---||| Return HTML display friendly SQL if Requested |||---> ! <cfif ATTRIBUTES.sqlOutputType IS "HTML" OR ATTRIBUTES.sqlOutputType IS "BOTH"> ! <cfset "CALLER.#ATTRIBUTES.htmlOutput#" = htmlSQL> ! </cfif> ! </cfif> ! ! <!-----------------------------------> ! <!--- Execute ALTER TABLE Command ---> ! <!-----------------------------------> ! <!--- If Execution was requested ... ---> ! <cfif ATTRIBUTES.execute> ! <!---<cfquery name="#ATTRIBUTES.queryName#" datasource="#ATTRIBUTES.dataSource#" username="#ATTRIBUTES.userName#" password="#ATTRIBUTES.password#"> ! <!--- Execute Generated rawSQL ---> ! #rawSQL# ! </cfquery>---> ! </cfif> ! </cfcase> ! </cfswitch> ! ! <!---+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ! === MySQL CREATE TABLE Syntax === ! ! ALTER [IGNORE] TABLE tbl_name alter_spec [, alter_spec ...] ! ! alter_specification: ! ADD [COLUMN] create_definition [FIRST | AFTER column_name ] ! or ADD [COLUMN] (create_definition, create_definition,...) ! or ADD INDEX [index_name] (index_col_name,...) ! or ADD PRIMARY KEY (index_col_name,...) ! or ADD UNIQUE [index_name] (index_col_name,...) ! or ADD FULLTEXT [index_name] (index_col_name,...) ! or ADD [CONSTRAINT symbol] FOREIGN KEY [index_name] (index_col_name,...) ! [reference_definition] ! or ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT} ! or CHANGE [COLUMN] old_col_name create_definition ! [FIRST | AFTER column_name] ! or MODIFY [COLUMN] create_definition [FIRST | AFTER column_name] ! or DROP [COLUMN] col_name ! or DROP PRIMARY KEY ! or DROP INDEX index_name ! or DISABLE KEYS ! or ENABLE KEYS ! or RENAME [TO] new_tbl_name ! or ORDER BY col ! or table_options ! ! create_definition: ! col_name type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT] ! [PRIMARY KEY] [reference_definition] ! or PRIMARY KEY (index_col_name,...) ! or KEY [index_name] (index_col_name,...) ! or INDEX [index_name] (index_col_name,...) ! or UNIQUE [INDEX] [index_name] (index_col_name,...) ! or FULLTEXT [INDEX] [index_name] (index_col_name,...) ! or [CONSTRAINT symbol] FOREIGN KEY [index_name] (index_col_name,...) ! [reference_definition] ! or CHECK (expr) ! ! type: ! TINYINT[(length)] [UNSIGNED] [ZEROFILL] ! or SMALLINT[(length)] [UNSIGNED] [ZEROFILL] ! or MEDIUMINT[(length)] [UNSIGNED] [ZEROFILL] ! or INT[(length)] [UNSIGNED] [ZEROFILL] ! or INTEGER[(length)] [UNSIGNED] [ZEROFILL] ! or BIGINT[(length)] [UNSIGNED] [ZEROFILL] ! or REAL[(length,decimals)] [UNSIGNED] [ZEROFILL] ! or DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL] ! or FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL] ! or DECIMAL(length,decimals) [UNSIGNED] [ZEROFILL] ! or NUMERIC(length,decimals) [UNSIGNED] [ZEROFILL] ! or CHAR(length) [BINARY] ! or VARCHAR(length) [BINARY] ! or DATE ! or TIME ! or TIMESTAMP ! or DATETIME ! or TINYBLOB ! or BLOB ! or MEDIUMBLOB ! or LONGBLOB ! or TINYTEXT ! or TEXT ! or MEDIUMTEXT ! or LONGTEXT ! or ENUM(value1,value2,value3,...) ! or SET(value1,value2,value3,...) ! ! index_col_name: ! col_name [(length)] ! ! reference_definition: ! REFERENCES tbl_name [(index_col_name,...)] ! [MATCH FULL | MATCH PARTIAL] ! [ON DELETE reference_option] ! [ON UPDATE reference_option] ! ! reference_option: ! RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---> --- 1,305 ---- ! <!---******************************************************************************************* ! * Copyright: MyDatabase Pilot is distributed under the terms of the GNU GPL license * ! * Template: Query/alterTable.cfm (Custom Tag) * ! * Purpose: - Executes and/or displays an ALTER TABLE command * ! * - In Start Mode, the alter table strings are generated and sent back to * ! * caller if requested * ! * - In End Mode, the Query is executed * ! * Inputs Required: - table String * ! * - execute Boolean * ! * - alterSpec Array of Structures * ! * Inputs Optional: - dataSource String * ! * - userName String * ! * - password String * ! * - sqlOutputType (RAW|HTML|BOTH) * ! * Outputs: - rawOutput String * ! * - htmlOutput String * ! * Other Requirements- This Custom Tag requires an end tag * ! ********************************************************************************************---> ! ! <!---||| Determine which execution mode this custom tag is in |||---> ! <cfswitch expression="#ThisTag.ExecutionMode#"> ! <!---||| If in start mode ... |||---> ! <cfcase value="start"> ! <!----------------------> ! <!--- Error Checking ---> ! <!----------------------> ! <!---||| Check for existence of Required Attributes |||---> ! <!--- This needs to be developed ---> ! ! <!---||| Check for proper data types, to ensure SQL syntax is correct |||---> ! <!--- This needs to be developed ---> ! ! <!--------------------------------------------> ! <!--- Generate ALTER TABLE Command Strings ---> ! <!--------------------------------------------> ! <!---||| Initialize Internal Variables |||---> ! <cfset rawSQL = "ALTER TABLE"> ! <cfset htmlSQL = "<span class=""KeyWord"">ALTER TABLE</span>"> ! ! <!---||| Table Name |||---> ! <cfset rawSQL = "#rawSQL# #ATTRIBUTES.table#"> ! <cfset htmlSQL = "#htmlSQL# <span class=""String"">#ATTRIBUTES.table#</span>"> ! ! <!---||| Alter Specifications |||---> ! <!--- Process each Alter Specification ----> ! <cfloop from="1" to="#arrayLen(ATTRIBUTES.alterSpec)#" index="i"> ! <!--- If this is not the first alter specification add a comma to the last alterSpec ---> ! <cfif i GT 1> ! <cfset rawSQL = "#rawSQL#,"> ! <cfset htmlSQL = "#htmlSQL#,"> ! </cfif> ! ! <!--- Determine the alterSpec format ---> ! <cfswitch expression="#ATTRIBUTES.alterSpec[i].format#"> ! <cfcase value="ADD COLUMN"> ! <!--- ADD COLUMN KeyWord ---> ! <cfset rawSQL = "#rawSQL# ADD COLUMN"> ! <cfset htmlSQL = "#htmlSQL#<br /><span class=""KeyWord"">ADD COLUMN</span>"> ! ! <!--- Column Name ---> ! <cfif ATTRIBUTES.alterSpec[i].colName IS ""> ! <cfset rawSQL = "#rawSQL# NameNotSpecified_#i#"> ! <cfset htmlSQL = "#htmlSQL# <span class=""Missing"">NameNotSpecified_#i#</span>"> ! <cfelse> ! <cfset rawSQL = "#rawSQL# #ATTRIBUTES.alterSpec[i].colName#"> ! <cfset htmlSQL = "#htmlSQL# <span class=""String"">#ATTRIBUTES.alterSpec[i].colName#</span>"> ! </cfif> ! ! <!--- Column Type ---> ! <cfif ATTRIBUTES.alterSpec[i].colType IS "" OR ATTRIBUTES.alterSpec[i].colType IS "Empty"> ! <cfset rawSQL = "#rawSQL# DataTypeNotSpecified_#i#"> ! <cfset htmlSQL = "#htmlSQL# <span class=""Missing"">DataTypeNotSpecified_#i#</span>"> ! <cfelse> ! <cfset rawSQL = "#rawSQL# #ATTRIBUTES.alterSpec[i].colType#"> ! <cfset htmlSQL = "#htmlSQL# <span class=""KeyWord"">#ATTRIBUTES.alterSpec[i].colType#</span>"> ! <!--- Type Options ---> ! <cfswitch expression="#ATTRIBUTES.alterSpec[i].colType#"> ! <cfcase value="VARCHAR,CHAR"> ! <!--- Add Length to Output Strings ---> ! <cfif ATTRIBUTES.alterSpec[i].length IS ""> ! <cfset rawSQL = "#rawSQL#(LengthNotSpecified_#i#)"> ! <cfset htmlSQL = "#htmlSQL#(<span class=""Missing"">LengthNotSpecified_#i#</span>)"> ! <cfelse> ! <cfset rawSQL = "#rawSQL#(#ATTRIBUTES.alterSpec[i].length#)"> ! <cfset htmlSQL = "#htmlSQL#(<span class=""Number"">#ATTRIBUTES.alterSpec[i].length#</span>)"> ! </cfif> ! <!--- Add Binary to Output Strings if Specified ---> ! <cfif ATTRIBUTES.alterSpec[i].binary> ! <cfset rawSQL = "#rawSQL# BINARY"> ! <cfset htmlSQL = "#htmlSQL# <span class=""KeyWord"">BINARY</span>"> ! </cfif> ! </cfcase> ! <cfcase value="TINYBLOB,BLOB,MEDIUMBLOB,LONGBLOB,TINYTEXT,TEXT,MEDIUMTEXT,LONGTEXT"> ! <!--- ! TINYBLOB ! BLOB ! MEDIUMBLOB ! LONGBLOB ! TINYTEXT ! TEXT ! MEDIUMTEXT ! LONGTEXT ! ---> ! </cfcase> ! <cfcase value="ENUM,SET"> ! <!--- ! ENUM(value1,value2,value3,...) ! SET(value1,value2,value3,...)</cfcase> ! ---> ! </cfcase> ! <cfcase value="TINYINT,SMALLINT,MEDIUMINT,INT,INTEGER,BIGINT"> ! <!--- Add Length to Output Strings if Specified ---> ! <cfif ATTRIBUTES.alterSpec[i].length IS NOT ""> ! <cfset rawSQL = "#rawSQL#(#ATTRIBUTES.alterSpec[i].length#)"> ! <cfset htmlSQL = "#htmlSQL#(<span class=""Number"">#ATTRIBUTES.alterSpec[i].length#</span>)"> ! </cfif> ! <!--- ! TINYINT[(length)] [UNSIGNED] [ZEROFILL] ! SMALLINT[(length)] [UNSIGNED] [ZEROFILL] ! MEDIUMINT[(length)] [UNSIGNED] [ZEROFILL] ! INT[(length)] [UNSIGNED] [ZEROFILL] ! INTEGER[(length)] [UNSIGNED] [ZEROFILL] ! BIGINT[(length)] [UNSIGNED] [ZEROFILL] ! ---> ! </cfcase> ! <cfcase value="REAL,FLOAT,DOUBLE"> ! <!--- Add Length and Decimals to Output Strings if Specified ---> ! <cfif ATTRIBUTES.alterSpec[i].length IS NOT ""> ! <cfset rawSQL = "#rawSQL#(#ATTRIBUTES.alterSpec[i].length#,#ATTRIBUTES.alterSpec[i].numberOfDecimals#)"> ! <cfset htmlSQL = "#htmlSQL#(<span class=""Number"">#ATTRIBUTES.alterSpec[i].length#</span>,<span class=""Number"">#ATTRIBUTES.alterSpec[i].numberOfDecimals#</span>)"> ! </cfif> ! <!--- ! REAL[(length,decimals)] [UNSIGNED] [ZEROFILL] ! DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL] ! FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL] ! ---> ! </cfcase> ! <cfcase value="DECIMAL,NUMERIC"> ! <!--- Add Length to Output Strings ---> ! <cfif ATTRIBUTES.alterSpec[i].length IS "" AND ATTRIBUTES.alterSpec[i].numberOfDecimals IS ""> ! <cfset rawSQL = "#rawSQL#(LengthNotSpecified_#i#,DecimalsNotSpecified_#i#)"> ! <cfset htmlSQL = "#htmlSQL#(<span class=""Missing"">LengthNotSpecified_#i#</span>,<span class=""Missing"">DecimalsNotSpecified_#i#</span>)"> ! <cfelseif ATTRIBUTES.alterSpec[i].length IS ""> ! <cfset rawSQL = "#rawSQL#(LengthNotSpecified_#i#,#ATTRIBUTES.alterSpec[i].numberOfDecimals#)"> ! <cfset htmlSQL = "#htmlSQL#(<span class=""Missing"">LengthNotSpecified_#i#</span>,<span class=""Number"">#ATTRIBUTES.alterSpec[i].numberOfDecimals#</span>)"> ! <cfelseif ATTRIBUTES.alterSpec[i].numberOfDecimals IS ""> ! <cfset rawSQL = "#rawSQL#(#ATTRIBUTES.alterSpec[i].length#,DecimalsNotSpecified_#i#)"> ! <cfset htmlSQL = "#htmlSQL#(<span class=""Number"">#ATTRIBUTES.alterSpec[i].length#</span>,<span class=""Missing"">DecimalsNotSpecified_#i#</span>)"> ! <cfelse> ! <cfset rawSQL = "#rawSQL#(#ATTRIBUTES.alterSpec[i].length#,#ATTRIBUTES.alterSpec[i].numberOfDecimals#)"> ! <cfset htmlSQL = "#htmlSQL#(<span class=""Number"">#ATTRIBUTES.alterSpec[i].length#</span>,<span class=""Number"">#ATTRIBUTES.alterSpec[i].numberOfDecimals#</span>)"> ! </cfif> ! ! <!--- ! DECIMAL(length,decimals) [UNSIGNED] [ZEROFILL] ! NUMERIC(length,decimals) [UNSIGNED] [ZEROFILL] ! ---> ! </cfcase> ! <cfcase value="DATE,TIME,DATETIME,YEAR,TIMESTAMP"> ! <!--- ! DATE ! TIME ! TIMESTAMP ! DATETIME ! ---> ! </cfcase> ! </cfswitch> ! </cfif> ! </cfcase> ! <!--- ToDo Cases: ---> ! <cfcase value="ADD INDEX"></cfcase> ! <cfcase value="ADD PRIMARY KEY"></cfcase> ! <cfcase value="ADD UNIQUE"></cfcase> ! <cfcase value="ADD FULLTEXT"></cfcase> ! <cfcase value="ADD FOREIGN KEY"></cfcase> ! <cfcase value="ALTER COLUMN"></cfcase> ! <cfcase value="CHANGE COLUMN"></cfcase> ! <cfcase value="MODIFY COLUMN"></cfcase> ! <cfcase value="DROP COLUMN"></cfcase> ! <cfcase value="DROP PRIMARY KEY"></cfcase> ! <cfcase value="DROP INDEX"></cfcase> ! <cfcase value="DISABLE KEYS"></cfcase> ! <cfcase value="ENABLE KEYS"></cfcase> ! <cfcase value="RENAME TO"></cfcase> ! <cfcase value="ORDER BY"></cfcase> ! <cfcase value="table_options"></cfcase> ! </cfswitch> ! </cfloop> ! ! <!---||| Terminate SQL Statement with Semicolon |||---> ! <cfset rawSQL = "#rawSQL#;"> ! <cfset htmlSQL = "#htmlSQL#;"> ! </cfcase> ! ! <!---||| If in end mode ... |||---> ! <cfcase value="end"> ! <!------------------> ! <!--- Output SQL ---> ! <!------------------> ! <!---||| If Output was requested... |||---> ! <cfif IsDefined("ATTRIBUTES.sqlOutputType")> ! <!---||| Return RAW SQL if Requested |||---> ! <cfif ATTRIBUTES.sqlOutputType IS "RAW" OR ATTRIBUTES.sqlOutputType IS "BOTH"> ! <cfset "CALLER.#ATTRIBUTES.rawOutput#" = rawSQL> ! </cfif> ! ! <!---||| Return HTML display friendly SQL if Requested |||---> ! <cfif ATTRIBUTES.sqlOutputType IS "HTML" OR ATTRIBUTES.sqlOutputType IS "BOTH"> ! <cfset "CALLER.#ATTRIBUTES.htmlOutput#" = htmlSQL> ! </cfif> ! </cfif> ! ! <!-----------------------------------> ! <!--- Execute ALTER TABLE Command ---> ! <!-----------------------------------> ! <!--- If Execution was requested ... ---> ! <cfif ATTRIBUTES.execute> ! <!---<cfquery name="#ATTRIBUTES.queryName#" datasource="#ATTRIBUTES.dataSource#" username="#ATTRIBUTES.userName#" password="#ATTRIBUTES.password#"> ! <!--- Execute Generated rawSQL ---> ! #rawSQL# ! </cfquery>---> ! </cfif> ! </cfcase> ! </cfswitch> ! ! <!---+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ! === MySQL CREATE TABLE Syntax === ! ! ALTER [IGNORE] TABLE tbl_name alter_spec [, alter_spec ...] ! ! alter_specification: ! ADD [COLUMN] create_definition [FIRST | AFTER column_name ] ! or ADD [COLUMN] (create_definition, create_definition,...) ! or ADD INDEX [index_name] (index_col_name,...) ! or ADD PRIMARY KEY (index_col_name,...) ! or ADD UNIQUE [index_name] (index_col_name,...) ! or ADD FULLTEXT [index_name] (index_col_name,...) ! or ADD [CONSTRAINT symbol] FOREIGN KEY [index_name] (index_col_name,...) ! [reference_definition] ! or ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT} ! or CHANGE [COLUMN] old_col_name create_definition ! [FIRST | AFTER column_name] ! or MODIFY [COLUMN] create_definition [FIRST | AFTER column_name] ! or DROP [COLUMN] col_name ! or DROP PRIMARY KEY ! or DROP INDEX index_name ! or DISABLE KEYS ! or ENABLE KEYS ! or RENAME [TO] new_tbl_name ! or ORDER BY col ! or table_options ! ! create_definition: ! col_name type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT] ! [PRIMARY KEY] [reference_definition] ! or PRIMARY KEY (index_col_name,...) ! or KEY [index_name] (index_col_name,...) ! or INDEX [index_name] (index_col_name,...) ! or UNIQUE [INDEX] [index_name] (index_col_name,...) ! or FULLTEXT [INDEX] [index_name] (index_col_name,...) ! or [CONSTRAINT symbol] FOREIGN KEY [index_name] (index_col_name,...) ! [reference_definition] ! or CHECK (expr) ! ! type: ! TINYINT[(length)] [UNSIGNED] [ZEROFILL] ! or SMALLINT[(length)] [UNSIGNED] [ZEROFILL] ! or MEDIUMINT[(length)] [UNSIGNED] [ZEROFILL] ! or INT[(length)] [UNSIGNED] [ZEROFILL] ! or INTEGER[(length)] [UNSIGNED] [ZEROFILL] ! or BIGINT[(length)] [UNSIGNED] [ZEROFILL] ! or REAL[(length,decimals)] [UNSIGNED] [ZEROFILL] ! or DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL] ! or FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL] ! or DECIMAL(length,decimals) [UNSIGNED] [ZEROFILL] ! or NUMERIC(length,decimals) [UNSIGNED] [ZEROFILL] ! or CHAR(length) [BINARY] ! or VARCHAR(length) [BINARY] ! or DATE ! or TIME ! or TIMESTAMP ! or DATETIME ! or TINYBLOB ! or BLOB ! or MEDIUMBLOB ! or LONGBLOB ! or TINYTEXT ! or TEXT ! or MEDIUMTEXT ! or LONGTEXT ! or ENUM(value1,value2,value3,...) ! or SET(value1,value2,value3,...) ! ! index_col_name: ! col_name [(length)] ! ! reference_definition: ! REFERENCES tbl_name [(index_col_name,...)] ! [MATCH FULL | MATCH PARTIAL] ! [ON DELETE reference_option] ! [ON UPDATE reference_option] ! ! reference_option: ! RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---> |