参考:

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. MySQL8.0.11安装后,使用CMD无法启动mysql服务

    首先,先把mysql的bin路径添加到系统环境变量 这样做可以,直接进入CMD后执行mysql服务,不需要进入mysql的bin文件路径去执行. 第一步:在MySQL的安装文件的bin目录(例如:C: ...

  2. C语言:判断字符串是否为回文,-函数fun将单向链表结点数据域为偶数的值累加起来。-用函数指针指向要调用的函数,并进行调用。

    //函数fun功能:用函数指针指向要调用的函数,并进行调用. #include <stdio.h> double f1(double x) { return x*x; } double f ...

  3. 最长公共子序列-Hdu1159

    Common Subsequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  4. 一个HTTP数据包的奇幻之旅

    我是一个HTTP数据包,不知谁创建了我,把我丢到这个房间. 突然,来了一个大汉,我吓得缩到角落. “该启程了,站起来”. “去哪里啊?” 我弱弱的问. “还能去哪里,你是一个数据包,当然要出远门,完成 ...

  5. EasyUI中使用自定义的icon图标

    我们在web开发中为了界面的更加漂亮,我们可能会使用EasyUI框架来帮我们实现一些好看的效果,那么在框架里面提供了很多的样式和图标,但是有时候自带的图标已经满足不了我们啦,这时候我们应该往里面加入我 ...

  6. 如何让div中的img图片显示在div下面。

    <!DOCTYPE html><html> <head> <meta charset="utf-8"> <title>& ...

  7. 洛谷P1991 无线通讯网(最小生成树性质+连通块)

    题目描述 国防部计划用无线网络连接若干个边防哨所.2 种不同的通讯技术用来搭建无线网络: 每个边防哨所都要配备无线电收发器:有一些哨所还可以增配卫星电话. 任意两个配备了一条卫星电话线路的哨所(两边都 ...

  8. linux(centos6.10)下去掉mysql的强密码验证

    vim /etc/my.cnf shift + G      光标移到最下方: o    进入插入模式,同时换行: 添加一行语句:  validate_password=OFF 保存退出. servi ...

  9. 中国社交电商最新展望,S-KOL-C正突围而出

    编辑 | 韩星 出品 | 于见(mpyujian) 通信技术.移动互联网的快速发展正加速国内电商平台的深度变革. 在这场以"社交"和"下沉市场"为关键词的电商之 ...

  10. redhat 7.6 流量监控命令、软件(2) iftop 监控网络IP实时流量

    1.安装iftop,先要安装flex.bison.libpcap编译安装 解压红箭头的两个文件 tar  -zxvpf  iftop-0.16.tar.gz tar  -zxvpf   libpcap ...