MySQL增删改查 在表格的增删改查中,查的内容是最多的,包括group by ,join,limit,union,alter,排序都是服务于查的 #sql语句数据行操作补充 #增加: #insert into table_name(字段1,字段2) values('属性1','属性2'),('属性1','属性2') 插入多行数据 #insert into t1(字段1,字段2) select 字段1,字段2 from t2; (某张表的某几列数据选择出来,插入) #删除:delete from
查询mysql支持的引擎 show engines; 查询mysql支持的字符集 show character set; 设置mysql默认存储引擎 set default_storage_engine = innodb; 设置mysql默认字符集 set character set utf8; 查看mysql有多少数据库 show databases; 选择数据库 use `db_test`; 数据库的增 create database `db_test` character set utf8
查询tablename 数据库中 以"_copy" 结尾的表 select table_name from information_schema.tables where table_schema='tablename' and table_type='base table' and table_name like '%_copy'; information_schema 是MySQL系统自带的数据库,提供了对数据库元数据的访问information_schema.tables 指数据
--查询tablename 数据库中 以"_copy" 结尾的表 select table_name from information_schema.tables where table_schema='tablename' and table_type='base table' and table_name like '%_copy'; --information_schema 是MySQL系统自带的数据库,提供了对数据库元数据的访问 --information_schema.tab
MySql : 有N张表,N未知,每张表都有一个字段(id),每张表的字段结构不完全一样,如何查询所有表里面所有id的最大值?如下图所示: 对上面三张表进行操作的话,结果应该为:9 SQL语句: select greatest( (select max(id) from table_1), (select max(id) from table_2), (select max(id) from table_3) )
1.MySql获取表结构信息 SELECT TABLE_NAME, TABLE_COMMENT FROM information_schema.`TABLES` WHERE TABLE_SCHEMA = 'dm' -- dm 是数据库名称,需替换 ORDER BY TABLE_NAME; 2.MySql获取字段信息 SELECT TABLE_NAME AS 'tableName', COLUMN_NAME AS 'columnName', COLUMN_COMMENT AS 'columnCom
1 前言 项目中排行榜刚好需要查数据库表然后给出编号,方案一,可以按条件查找出来,然后再按数组序号给编号,但是如果要查表出来直接看,就不太够用了:方案二,就是用代码帮忙编号.参考了网上一些代码,然后发现方法都有一个样的,然后这边只是作为记录使用,方便查找. 2 代码 SELECT province_id, province_name, gdp, (@i :=@i + 1) AS No FROM province, (SELECT @i := 0) AS it ORDER BY gdp DESC