一、查询
1、获取mysql的所有数据库名
select schema_name from information_schema.schemata;
2、获取指定数据库dev所有表名
select table_name from information_schema.tables where table_schema='dev';
3、获取数据库dev中以’case_data’开头的表名
select table_name from information_schema.tables where table_name like 'case_data%' and table_schema='dev';
4、获取数据库dev中attach表的列信息
select column_name from information_schema.columns where table_name = 'attach' and table_schema='dev';
二、删除
1、清空数据库表数据
删除数据库表area所有数据并清除索引
truncate area;
删除数据库表area所有数据不清除索引
delete from area;
三、更新
三、更新
四、增加
1、创建数据库temp
CREATE DATABASE `temp` CHARACTER SET 'utf8' COLLATE 'utf8_general_ci';
2、创建数据库表bed
CREATE TABLE `bed` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
`name` varchar(128) NOT NULL DEFAULT '' COMMENT '名称',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
`cash_charge` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '价格',
`status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0-正常 1-禁用',
PRIMARY KEY (`id`) USING BTREE,
KEY `cash_charge` (`cash_charge`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=531865 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='家具表';