mysql 提取 schema,table,column names
参考:
https://dzone.com/articles/how-use-linkedin-market-your
表空间信息
https://coderanch.com/t/300498/databases/Java-find-List-tablespaces-database
getCatalogs()
存储过程
https://dev.mysql.com/doc/refman/5.7/en/routines-table.html
注释
https://dev.mysql.com/doc/refman/8.0/en/columns-table.html
外键
https://dev.mysql.com/doc/refman/5.5/en/constraint-foreign-key.html
- package com.dataconnect.test.util;
- import java.sql.Connection;
- import java.sql.DatabaseMetaData;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- public class SchemaDetailsTest {
- private static Logger log = LoggerFactory
- .getLogger(SchemaDetailsTest.class);
- public static void main(String args[]) throws Exception {
- String databaseName = "myDbName";
- String userName = "username";
- String password = "password";
- String mySQLPort = "3306";
- String hostUrl = "127.0.0.1";
- // Setup the connection with the DB
- Class.forName("com.mysql.jdbc.Driver");
- Connection conn = DriverManager.getConnection("jdbc:mysql://" + hostUrl
- + ":" + mySQLPort, userName, password);
- // --- LISTING DATABASE SCHEMA NAMES ---
- ResultSet resultSet = conn.getMetaData().getCatalogs();
- while (resultSet.next()) {
- log.info("Schema Name = " + resultSet.getString("TABLE_CAT"));
- }
- resultSet.close();
- // --- LISTING DATABASE TABLE NAMES ---
- String[] types = { "TABLE" };
- resultSet = conn.getMetaData()
- .getTables(databaseName, null, "%", types);
- String tableName = "";
- while (resultSet.next()) {
- tableName = resultSet.getString(3);
- log.info("Table Name = " + tableName);
- }
- resultSet.close();
- // --- LISTING DATABASE COLUMN NAMES ---
- DatabaseMetaData meta = conn.getMetaData();
- resultSet = meta.getColumns(databaseName, null, tableName, "%");
- while (resultSet.next()) {
- log.info("Column Name of table " + tableName + " = "
- + resultSet.getString(4));
- }
- }
- }
mysql 提取 schema,table,column names的更多相关文章
- Oracle :value too large for column "SCHEMA"."TABLE"."COLUMN" (actual: 519, maximum: 500)的解决方案
原因:我是使用 CREATE TABLE XXX AS subquery 进行创建的数据表,主要是将相关的数据聚合在一起,然后通过导出为SQL脚本文件,进行导入到新库中,导致部分INSERT INTO ...
- mysql切换数据库提示警告:Reading table information for completion of table and column names
登录数据库后,选择数据库时发现以下提示, mysql> use testReading table information for completion of table and column ...
- MySQL Reading table information for completion of table and column names
打开数据库是发现提示: mysql> show databases; +--------------------+ | Database | +--------------------+ | b ...
- Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -
mysql -A不预读数据库信息(use dbname 更快)—Reading table information for completion of table and column names Y ...
- 解决:Reading table information for completion of table and column names
mysql -A不预读数据库信息(use dbname 更快)—Reading table information for completion of table and column names Y ...
- Reading table information for completion of table and column names
mysql> use ad_detail_page;Reading table information for completion of table and column namesYou c ...
- msyql error: Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
mysql> use mydb Reading table information for completion of table and column names You can turn o ...
- Replication-Replication Distribution Subsystem: agent xxxxxx failed. Column names in each table must be unique
最近遇到一个关于发布订阅(Replication)的奇葩问题,特此记录一下这个案例.我们一SQL SERVER数据库服务器出现大量告警.告警信息如下所示: DESCRIPTION: Replicati ...
- MySQL 8 mysql system schema
在大的分类上:mysql schema包括存储数据库对象元数据的数据字典表和用于其他操作目的的系统表 数据字典表和系统表一般使用InnoDB存储引擎 与之前的版本不同,数据字典表和系统表存储在数据目录 ...
随机推荐
- HBase的完全分布式搭建
一.HBase的安装模式 ①单机安装:不依赖于Hadoop的HDFS,配置完即可使用,好处是便于测试,坏处是不具备分布式数据存储的能力. ②伪分布式安装:单台主机模拟真实环境. ③完全分布式安装:多台 ...
- try catch和if else
当错误发生时,当事情出问题时,JavaScript 引擎通常会停止,并生成一个错误消息.描述这种情况的技术术语是:JavaScript 将抛出一个错误. try 语句允许我们定义在执行时进行错误测试的 ...
- 4_3 救济金发放(UVa133)<子过程/函数设计>
为了缩短领救济品的队伍,NNGLRP决定了以下策略:每天所有来申请救济品的人会被放在一个大圆圈,面朝里面.标明一个人为编号1号,其他的就从那个人开始逆时针开始编号直到N.一个官员一开始逆时针数,数k个 ...
- mysql5.7修改root密码
use mysql; update mysql.user set authentication_string=password('123456') where user='root'; flush p ...
- Linux 笔记:文件名
文件名 Linux 系统区分英文字符的大小写.比如,myfile, Myfile 和 myFILE表示的是三个不同的文件.同样,用户密码和登录名也需要区分大小写(这里沿用了Unix 和 C 语言的命名 ...
- Java基础题目
题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子对数为多少? 程序分析:兔子的规律为数列1,1,2,3,5,8, ...
- spring boot中配置文件中变量的引用
配置文件中 变量的自身引用 ${名称} java文件中引用:非静态变量 之间在变量上面注释@Value("${名称}") 静态变量 在set方法上注释@Value("$ ...
- vue修改当前页样式不影响公共样式的方法
在项目开发中需要对一些标签进行样式修改但是每次修改之后其他页面的样式也会跟着改变, 在网上找了很多方法都不好使后来大神告诉我一种方法很好用分享给大家. 1:首先在template标签下的第一个div中 ...
- 后端——框架——持久层框架——Mybatis——《Mybatis从入门到精通》读书笔记——初篇
1.Mybatis知识点 框架的知识点大致可以分为三个部分 基础: 介绍编写增,删,改,查: 动态标签: config配置文件 Mapper配置文件 插件:常见的插件有三个 pageHelper:分页 ...
- struct和class定义类的区别
(1)struct定义的类.struct定义的类,其方法和属性都是公有的(public).因此,外部可以直接访问其内部数据. (2)class定义的类.class定义的类,默认情况下是私有的(priv ...