[mysql新增空格字段]MySQL增加和修改表的字段
删掉两个表
DROP TABLE IF EXISTS [表名]
DROP TABLE IF EXISTS new_table;
减少两个表头
ALTER TABLE [表名] ADD [表头名] [表头类别] [与否为空];
ALTER TABLE table_name ADD column varchar(32) not Null;
删掉两个表头
ALTER TABLE [表名] DROP [表头名];
ALTER TABLE table_name DROP szBusiness;
修正某一表的表头名称及选定为空及非空
ALTER TABLE [表名] change [原表头名] [新表头名] [表头类别] [与否为空];
ALTER TABLE table_name change column column_new varchar(32) default Null;
修正某一表的表头类别及选定为空及非空
ALTER TABLE [表名] modify [表头名] [表头类别] [与否为空];
ALTER TABLE table_name modify column_new varchar(64) default Null;
在选定的表头后面减少两个表头
ALTER table [表名] ADD [新表头名] [表头类别] [与否为空] [注释] after [已存在的表头名];
ALTER table users_new ADD realname varchar(32) DEFAULT NULL comment "姓名" after nickname;
查询表里面所有数据
SELECT * FROM [表名];
SELECT * FROM table_name;
有关索引:--------------------------------------------------------------------------------------------------------------
建表时创建索引
CREATE TABLE users_new(
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
uid INT NOT NULL,
username varchar(32) NOT NULL comment "用户名",
password varchar(32) NOT NULL comment "密码",
nickname varchar(64) NOT NULL comment "昵称",
sex int(4) DEFAULT 0 comment "0女,1男",
age int(4) DEFAULT 18 comment "年龄",
mobile varchar(32) DEFAULT NULL comment "手机",
birthday datetime DEFAULT NULL comment "生日",
createdate datetime NOT NULL comment "创建日期",
index idx_login(username, password)
);
单独创建常规索引
CREATE index idx_info on users_new(sex, age);
删掉索引
drop index idx_info on users_new;
添加INDEX(普通索引)
ALTER TABLE `table_name` ADD INDEX index_name ( `column` )
添加FULLTEXT(全文索引)
ALTER TABLE `table_name` ADD FULLTEXT (`column`)
添加多列索引
ALTER TABLE `table_name` ADD INDEX index_name ( `column1`, `column2`, `column3` )