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存储引擎 与之前的版本不同,数据字典表和系统表存储在数据目录 ...
随机推荐
- python、js实现WGS84、高德(火星)、百度坐标转换
在日常工作学习中常会涉及到WGS84.高德(火星/谷歌).百度三种空间坐标系的坐标转换,本文将通过python.js两种语言实现坐标系的转换. 坐标系说明: wgs84:为一种大地坐标系,也是目前广泛 ...
- python练习:编写一个程序,要求用户输入一个整数,然后输出两个整数root和pwr,满足0<pwr<6,并且root**pwr等于用户输入的整数。如果不存在这样一对整数,则输入一条消息进行说明。
python练习:编写一个程序,要求用户输入一个整数,然后输出两个整数root和pwr,满足0<pwr<6,并且root**pwr等于用户输入的整数.如果不存在这样一对整数,则输入一条消息 ...
- ASP.NET Core搭建多层网站架构【4-工作单元和仓储设计】
2020/01/28, ASP.NET Core 3.1, VS2019, Microsoft.EntityFrameworkCore.Relational 3.1.1 摘要:基于ASP.NET Co ...
- 2020年python学习进阶方向
相信很多友人在学习python过程都会遇到很多 虽然python入门很容易 但是难免会遇到瓶颈 遇到问题没人交流 很难提升 对此 给你们简单指点学习方向 1.认识python linux基本 ...
- Halcon blob分析基本处理步骤
Halcon,blob分析 应用场景,二值化后的灰度图像对比度清晰 基本处理流程 1 读取图片 read_image(变量名,'路径') //halcon字符串使用单引号'' 2 预处理 2.1 RO ...
- GIT 协同开发
Git 是一个开源的分布式版本控制系统,用于敏捷高效的处理任何项目的版本问题.Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制软件.与cvs, ...
- 17 JavaScript Cookies
关于Cookie: Cookie是存储在电脑上的文本文件中的一些数据 Cookie致力于解决如何在连接关闭后记录客户单的用户信息 Cookie以键值对的形式存储,例如username=John Doe ...
- C语言-错误处理
标记程序的运行状态和控制主要有以下几种:break/continue/return/参数的返回值/exit(int n)_exit() atexit((*p)(参数列表)): 1 break:用在开关 ...
- centos7搭建hadoop2.10完全分布式
本篇介绍在centos7中大家hadoop2.10完全分布式,首先准备4台机器:1台nn(namenode);3台dn(datanode) IP hostname 进程 192.168.30.141 ...
- 设计模式课程 设计模式精讲 3-10 里氏替换原则coding
1 代码演练 1.1 继承关系判别(是否是真正意义的继承) 1.2 入参控制 1.3 出参控制 1 代码演练 1.1 继承关系判别(是否是真正意义的继承)(其实我觉得这个例子有点牵强) 1.1.1 反 ...