1.导出一个数据表中的部分字段数据;
SELECT `lUin` , `iSumMoney` , `iAreaId` FROM tbtest INTO OUTFILE 'C:/Users/Administrator/Desktop/test/123.xlsx'
2.导入数据到一个表的相应字段中;
LOAD DATA INFILE 'data.txt' INTO TABLE db2.gs_table;
LOAD DATA INFILE 'data.txt' INTO TABLE table2 FIELDS TERMINATED BY ',';
3.根据iUin的总的money来进行排序;
select lUin,sum(iSumMoney) as 'iSumScore' from tbUserMoneyTotal group by lUin order by iSumScore desc,lUin asc ;
4.显示一个表的结构信息;
show create table tbname;
5.同一个数据库中拷贝一个表中的部分字段数据到另外一个表中;
INSERT INTO 目标表 (字段1, 字段2, ...) SELECT 字段1, 字段2, ... FROM 来源表;
6.删除主键索引
drop index 索引名 on table ;//删除普通索引
ALTER TABLE `test` DROP PRIMARY KEY //删除主键索引
7.在指定的字段后面添加一个字段
ALTER TABLE `表名` ADD `feetype` INT( 11 ) UNSIGNED NOT NULL COMMENT '注释信息' AFTER `matchfeename` ;
8.SHOW KEYS FROM table 查看表中的所有索引
9.GRANT USAGE ON *.* TO 'root'@'%' IDENTIFIED BY 'public' WITH GRANT OPTION;//为用户授权
grant all privileges on *.* to 'root'@'%' identified by 'public';//用户创建授权