参考:

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的更多相关文章

  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. 【嵌入式】ARM9复习

    一.嵌入式系统基础 二.ARM处理器 1. 在每条指令后,用;//注释这条指令的寻址方式,以及实现的功能(25分) 注:变址寻址需要标注是基址加偏移.还是基址加索引,是前变址还是后变址.SUB SP, ...

  2. Java常用API——Arrays工具类

    介绍:Arrays工具类提供了一些可以直接操作数组的方法,以下是一些常用方法: int binarySearch(type[] a, type key):要求数组a元素升序排列,使用二分法搜索key的 ...

  3. Linux - 删除文件的正确方式

    mv <file> /tmp/ cp <file> /opt/file.bak rm

  4. Ubuntu Rabbitmq 安装与配置

    原文链接:http://blog.csdn.net/rickey17/article/details/72756766 添加源 新增公钥(不加会有警告) 更新源 安装rabbitmq-server e ...

  5. beyond compare 用法

    1.过滤器用法:点击小眼睛(回话-->回话设置)打开过滤器界面----设置多个过滤文件或目录直接使用回车键 2.比较时最好先设置编码以防出现乱码问题 工具-->文件格式. 3.比较时出现乱 ...

  6. 为什么阿里Java手册推荐慎用 Object 的 clone 方法来拷贝对象

    图片若无法显示,可至掘金查看https://juejin.im/post/5d425230f265da039519d248 前言 在阿里Java开发手册中,有这么一条建议:慎用 Object 的 cl ...

  7. flink整合kafka报错 WARN - Bootstrap broker ip:9092 disconnected

    WARN - The configuration 'zookeeper.connect' was supplied but isn't a known config.WARN - The config ...

  8. I/O-<File实例>

    File n=new File("D:\2016.txt"); System.out.println("文件是否存在"+n.exists()); System. ...

  9. [ NLP ] CS224N 学习笔记

    Lecture1 One-Hot 定义:用N位状态寄存器编码N个状态,每个状态都有独立的寄存器位,且这些寄存器位中只有一位有效,说白了就是只能有一个状态.即保证每个样本中的每个特征只有1位处于状态1, ...

  10. Android Studio中 安卓模拟器 联网

    方案一:之前做测试的时候发现虚拟机无法联网(浏览器打开 www.baidu.com, 显示 403 forbidden): 解决方案:关闭已经打开的虚拟机,进入到 SDK 安装目录下,按住 shift ...