参考:

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

  1. package com.dataconnect.test.util;
  2. import java.sql.Connection;
  3. import java.sql.DatabaseMetaData;
  4. import java.sql.DriverManager;
  5. import java.sql.ResultSet;
  6. import org.slf4j.Logger;
  7. import org.slf4j.LoggerFactory;
  8. public class SchemaDetailsTest {
  9. private static Logger log = LoggerFactory
  10. .getLogger(SchemaDetailsTest.class);
  11. public static void main(String args[]) throws Exception {
  12. String databaseName = "myDbName";
  13. String userName = "username";
  14. String password = "password";
  15. String mySQLPort = "3306";
  16. String hostUrl = "127.0.0.1";
  17. // Setup the connection with the DB
  18. Class.forName("com.mysql.jdbc.Driver");
  19. Connection conn = DriverManager.getConnection("jdbc:mysql://" + hostUrl
  20. + ":" + mySQLPort, userName, password);
  21. // --- LISTING DATABASE SCHEMA NAMES ---
  22. ResultSet resultSet = conn.getMetaData().getCatalogs();
  23. while (resultSet.next()) {
  24. log.info("Schema Name = " + resultSet.getString("TABLE_CAT"));
  25. }
  26. resultSet.close();
  27. // --- LISTING DATABASE TABLE NAMES ---
  28. String[] types = { "TABLE" };
  29. resultSet = conn.getMetaData()
  30. .getTables(databaseName, null, "%", types);
  31. String tableName = "";
  32. while (resultSet.next()) {
  33. tableName = resultSet.getString(3);
  34. log.info("Table Name = " + tableName);
  35. }
  36. resultSet.close();
  37. // --- LISTING DATABASE COLUMN NAMES ---
  38. DatabaseMetaData meta = conn.getMetaData();
  39. resultSet = meta.getColumns(databaseName, null, tableName, "%");
  40. while (resultSet.next()) {
  41. log.info("Column Name of table " + tableName + " = "
  42. + resultSet.getString(4));
  43. }
  44. }
  45. }

mysql 提取 schema,table,column names的更多相关文章

  1. Oracle :value too large for column "SCHEMA"."TABLE"."COLUMN" (actual: 519, maximum: 500)的解决方案

    原因:我是使用 CREATE TABLE XXX AS subquery 进行创建的数据表,主要是将相关的数据聚合在一起,然后通过导出为SQL脚本文件,进行导入到新库中,导致部分INSERT INTO ...

  2. mysql切换数据库提示警告:Reading table information for completion of table and column names

    登录数据库后,选择数据库时发现以下提示, mysql> use testReading table information for completion of table and column ...

  3. MySQL Reading table information for completion of table and column names

    打开数据库是发现提示: mysql> show databases; +--------------------+ | Database | +--------------------+ | b ...

  4. 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 ...

  5. 解决: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 ...

  6. 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 ...

  7. 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 ...

  8. Replication-Replication Distribution Subsystem: agent xxxxxx failed. Column names in each table must be unique

    最近遇到一个关于发布订阅(Replication)的奇葩问题,特此记录一下这个案例.我们一SQL SERVER数据库服务器出现大量告警.告警信息如下所示: DESCRIPTION: Replicati ...

  9. MySQL 8 mysql system schema

    在大的分类上:mysql schema包括存储数据库对象元数据的数据字典表和用于其他操作目的的系统表 数据字典表和系统表一般使用InnoDB存储引擎 与之前的版本不同,数据字典表和系统表存储在数据目录 ...

随机推荐

  1. HBase的完全分布式搭建

    一.HBase的安装模式 ①单机安装:不依赖于Hadoop的HDFS,配置完即可使用,好处是便于测试,坏处是不具备分布式数据存储的能力. ②伪分布式安装:单台主机模拟真实环境. ③完全分布式安装:多台 ...

  2. try catch和if else

    当错误发生时,当事情出问题时,JavaScript 引擎通常会停止,并生成一个错误消息.描述这种情况的技术术语是:JavaScript 将抛出一个错误. try 语句允许我们定义在执行时进行错误测试的 ...

  3. 4_3 救济金发放(UVa133)<子过程/函数设计>

    为了缩短领救济品的队伍,NNGLRP决定了以下策略:每天所有来申请救济品的人会被放在一个大圆圈,面朝里面.标明一个人为编号1号,其他的就从那个人开始逆时针开始编号直到N.一个官员一开始逆时针数,数k个 ...

  4. mysql5.7修改root密码

    use mysql; update mysql.user set authentication_string=password('123456') where user='root'; flush p ...

  5. Linux 笔记:文件名

    文件名 Linux 系统区分英文字符的大小写.比如,myfile, Myfile 和 myFILE表示的是三个不同的文件.同样,用户密码和登录名也需要区分大小写(这里沿用了Unix 和 C 语言的命名 ...

  6. Java基础题目

    题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子对数为多少? 程序分析:兔子的规律为数列1,1,2,3,5,8, ...

  7. spring boot中配置文件中变量的引用

    配置文件中 变量的自身引用 ${名称} java文件中引用:非静态变量 之间在变量上面注释@Value("${名称}")  静态变量 在set方法上注释@Value("$ ...

  8. vue修改当前页样式不影响公共样式的方法

    在项目开发中需要对一些标签进行样式修改但是每次修改之后其他页面的样式也会跟着改变, 在网上找了很多方法都不好使后来大神告诉我一种方法很好用分享给大家. 1:首先在template标签下的第一个div中 ...

  9. 后端——框架——持久层框架——Mybatis——《Mybatis从入门到精通》读书笔记——初篇

    1.Mybatis知识点 框架的知识点大致可以分为三个部分 基础: 介绍编写增,删,改,查: 动态标签: config配置文件 Mapper配置文件 插件:常见的插件有三个 pageHelper:分页 ...

  10. struct和class定义类的区别

    (1)struct定义的类.struct定义的类,其方法和属性都是公有的(public).因此,外部可以直接访问其内部数据. (2)class定义的类.class定义的类,默认情况下是私有的(priv ...