在 Mysql 的 information_schema 库中 COLUMNS 表中存放了所有表的所有列. using MySql.Data.MySqlClient; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static voi…
MySQL将表a中查询的数据插入到表b中 假设表b存在 insert into b select * from a; 假设表b不存在 create table b as select * from a; 扩展: 将b表中的某写字段值插入到a表中 insert into a (userID,userName) select b.userID,b.userName from tr_ajax_chat_messages; 将a表和b表userID相等的值保存到a表 update a set a.use…
mysql修改列 mysql增加列,修改列名.列属性,删除列语句 mysql修改表名,列名,列类型,添加表列,删除表列 alter table test rename test1; --修改表名 alter table test add column name varchar(10); --添加表列 alter table test drop column name; --删除表列 alter table test modify address char…
1.给表添加列 ALTER TABLE supplier_seller ADD COLUMN company_id INT NULL COMMENT '供应主体id'; 默认情况下,添加的列会添加到最后一列. 如果要求添加到指定位置,语句如下: ALTER TABLE supplier_seller ADD COLUMN company_id INT NULL COMMENT '供应主体id' AFTER mdm_info_json; 如果想要添加到第一列,语句如下: ALTER TABLE s…
查看所有数据库中所有表的数据库名和表名 SELECT `TABLES`.`TABLE_SCHEMA`, `TABLES`.`TABLE_NAME` FROM `information_schema`.`TABLES` 查看所有数据库中所有基本表的数据库名和表名 SELECT `TABLES`.`TABLE_SCHEMA`, `TABLES`.`TABLE_NAME` FROM `information_schema`.`TABLES` WHERE `TABLES`.`TABLE_TYPE` =…
SELECT COLUMN_NAME as '列名' ,DATA_TYPE as '字段类型' ,COLUMN_TYPE as '长度加类型' FROM information_schema.`COLUMNS` where TABLE_SCHEMA like '库名' and TABLE_NAME like '表名'…