Mysql syntax can have additional columns in the column before the judge whether there

2010-04-12  来源:本站原创  分类:Database  人气:234 

Mysql syntax can be no direct increase in the column comes out on top to judge whether the Cunzai, need to write a stored Guocheng do the same Ren Wu, Xiamianlizai yes: increases in sales_order Biao in a has_sent out

drop procedure if exists schema_change;
delimiter ';;';
create procedure schema_change() begin
if exists (select * from information_schema.columns where table_name = 'sales_order' and column_name = 'has_sent') then
                alter table sales_order drop column has_sent;
end if;
alter table sales_order add column has_sent boolean;
end;;
delimiter ';';
call schema_change();
drop procedure if exists schema_change;

This code can work only in MySQL5.0 above.

相关文章
  • Mysql syntax can have additional columns in the column before the judge whether there 2010-04-12

    Mysql syntax can be no direct increase in the column comes out on top to judge whether the Cunzai, need to write a stored Guocheng do the same Ren Wu, Xiamianlizai yes: increases in sales_order Biao in a has_sent out drop procedure if exists schema_c

  • mysql syntax entry 3 2011-02-28

    7.4.13 used in conjunction with GROUP BY clause function If you do not include a statement GROUP BY clause to use an aggregate function, which is equivalent to the aggregate of all lines. COUNT(expr) Return statement by a SELECT rows retrieved the nu

  • mysql syntax entry 5 2011-02-28

    7.17 UPDATE syntax UPDATE [LOW_PRIORITY] tbl_name SET col_name1=expr1,col_name2=expr2,... [WHERE where_definition] [LIMIT #] UPDATE updated with new values of existing rows in a table column, SET clause indicates which columns to modify and they shou

  • MySQL syntax statement Daquan 2010-09-03

    Daquan a MySQL syntax statement, SQL intensive structured query language (SQL) is the standard for relational database query language, which includes the same number of keywords and syntax, ease of database elements (such as tables, indexes, fields,

  • mysql syntax entry 6 2011-02-28

    GRANT and REVOKE syntax GRANT priv_type [(column_list)] [, priv_type [(column_list)] ...] ON {tbl_name | * | *.* | db_name.*} TO user_name [IDENTIFIED BY 'password'] [, user_name [IDENTIFIED BY 'password'] ...] [WITH GRANT OPTION] REVOKE priv_type [(

  • oracle delete column to modify the table to add columns to modify column 2010-11-16

    tag: oracle modify the table; sql add columns; sql delete column; sql to modify column 1. Increase the column ALTER TABLE table_name ADD (column datatype [DEFAULT EXPR] [, column datatype ...]); For example: SQL> ALTER TABLE emp01 ADD eno NUMBER (4);

  • MySQL syntax statements Daquan 2010-11-01

    Daquan a MySQL statement syntax, SQL Express structured query language (SQL) is the standard for relational database query language, which includes the same number of keywords and syntax, ease of database elements (such as tables, indexes, fields, et

  • Start a mysql syntax 2011-02-26

    Function and syntax: mod (n, m) = n% m Remainder Bitwise | & ~ bits or, respectively, bit and, bit-wise inverted BIT_COUNT (N) find the number of bits n Logical not!, Or | |, and & &, Comparison operators <,>, =, <>! =, <=,>

  • [Transfer] MySQL syntax mainly Detailed 2011-09-07

    Reprinted from: http://varyall.iteye.com/blog/806928 1, SQL Express Structured query language (SQL) is used to query relational databases the standard language, which includes the same number of keywords and syntax, ease of database elements (such as

  • MySQL Syntax Summary 2010-07-09

    1. Database and table to create a database: create database databaseName Delete the database: drop database databaseName Show Database: show databases; Database Switch: use databaseName; Create table: create table <tableName> (<field1> <fie

  • Introduction 2 mysql syntax 2011-02-28

    7.4.10 String Functions If the result is longer than the server parameters max_allowed_packet, string value function returns NULL. See 10.2.3 Tuning Server Parameters . For the location of operations for the string, the first location is marked as 1.

  • mysql syntax compared with MongoDB 2011-08-10

    SQL Statement Mongo Query Language Statement CREATE TABLE USERS (a Number, b Number) db.createCollection( "mycoll" , {capped:true , size:100000}) INSERT INTO USERS VALUES (1,1) db.users.insert ({a: 1, b: 1}) SELECT a, b FROM users db.users.find

  • Mysql --- on the field length displayed in the column width does not limit the range of values stored within, or specify the column width limit in excess of the value of the show 2010-05-06

    MySQL supports all standard SQL numeric data types. These types include strict numerical data types (INTEGER, SMALLINT, DECIMAL, and NUMERIC), and approximate numeric data types (FLOAT, REAL and DOUBLE PRECISION). Keyword INT is a synonym for INTEGER

  • mysql 日期字段 的异常 Data truncated for column 的处理 2011-12-17

    mysql 的date类型 的支持范围是1000-01-01到9999-12-31 datetime类型的支持范围是1000-01-01 00:00:00 到 9999-12-31 23:59:59 如果尝试把超出范围的值插入数据库中,则会报标题中的错误. 有效的处理方法有两种: 1.程序中检查日期的范围,当超出时给出提示或其他处理 2.在 mysql 安装目录的 my.ini 里找到sql-mode="STRICT_TRANS_TABLES,NO_AUTO_Create_USER,NO_ENG

  • mysql 4 syntax entry 2011-02-28

    7.11 DELETE syntax DELETE [LOW_PRIORITY] FROM tbl_name [WHERE where_definition] [LIMIT rows] DELETE removed from tbl_name table to meet the conditions given by the where_definition line, and returns the number of deleted records. If you issue a no WH

  • The basic syntax of mysql stored procedure articles 2010-06-24

    Learning the basic grammar of the main reference to the mysql User's Guide Mysql database stored procedure needs to have proc Table. The table created during the MySQL 5.1 installation. If you are upgrading from an earlier version to MySQL 5.1, make

  • MySQl the Alter statement syntax 2010-10-13

    ALTER TABLE statement for the existing table to add, modify, or delete columns. alter_specification: ADD [COLUMN] create_definition [First | After column_name] or ADD INDEX [index_name] (index_col_name ,...) or ADD PRIMARY KEY (index_col_name ,...) o

  • Basic syntax mysql database 2011-03-10

    Start: net start mySql; Enter: mysql-u root -p/mysql-h localhost-u root-p databaseName; Listed in the database: show databases; Select a database: use databaseName; List form: show tables; Display table column attributes: show columns from tableName;

  • MySQL Command Syntax and management 2011-03-10

    If you previously installed, uninstall the previous version # Rpm-e - nodeps mysql-3.23.58-2.3 Server installation: # Rpm-ivh MySQL-server-5.0.9-0.i386.rpm Shown below: warning: MySQL-server-5.0.9-0.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5

  • load data infile mysql import data usage 2010-09-01

    We often import the data! mysql import an efficient way, that is, load data infile look at the following case illustrates Basic syntax: load data [low_priority] [local] infile 'file_name txt' [replace | ignore] into table tbl_name [Fields [Terminated