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存储引擎 与之前的版本不同,数据字典表和系统表存储在数据目录 ...
随机推荐
- vCPU 和 CPU 的关系
vCPU 和 pCPU 的关系不是数量,当被底层虚拟化之后,任何一个 vCPU 都是用到所有的 pCPU 核心总体的百分比,不是某一个核心这么去看的,并没有对应的关系,也不是一个很绝对的分配到具体某个 ...
- django 中url与path小记
1. 在django 2.0中增加了一些新的特性 更简单的URL路由语法 (Simplified URL routing syntax) admin应用的针对移动设备的优化改进(Mobile-frie ...
- 【代码审计】VAuditDemo 命令注入漏洞
一般PHP中可以使用下列函数来执行外部的应用程序或命令 system() exec() passthru() shell_exec() 跟踪$cmd --> 跟进$target,发现传递给tar ...
- werkeug的WSGI服务器解析
werkeug的WSGI服务器解析 1. WSGI 1.1. wsgi与flask flask默认的wsgi引用自wekurg 声明app:FLASK对象 app.run() run_ ...
- window系统mysql安装后获取默认密码
未设置密码,获取默认密码方法 第一步:进去mysql根目录下,如果没有data文件夹可以新建一个,找不到my.ini文件也新建一个(在根目录下创建的my.ini,重新配置的参数会覆盖源文件的参数,所以 ...
- 任意值运动框架Move模块 js
function getStyle(obj, name) { if (obj.currentStyle) { return obj.currentStyle[name]; } else { retur ...
- 使用注解配置Servlet3.0
从Servlet3.0开始支持使用注解来配置. 注解只是代替了一部分的web.xml的 配置,通常在针对单个Servlet的配置时(比如Servlet的资源名称)使用注解 web.xml:优势在于解决 ...
- location练习!(重点)
写location最重要的就是hosts文件,添加一次域名跳转就得添加一条hosts文件 hosts文件: 192.168.200.120 www.a.com 192.168.200.119 www. ...
- mysql 官方读写分离方案
mysql 8.0 集群模式下的自动读写分离方案 问题 多主模式下的组复制,看起来挺好,起始问题和限制很多.而且中断一个复制就无法配置了 多主模式下,innodbcluster 等于是无用的,不需要自 ...
- cmd设置utf8编码
在中文windows系统中,如果一个文本文件是utf-8编码的,那么在cmd.exe命令行窗口(所谓的dos窗口)中不能正确显示文件中的内容.在默认情况下,命令行窗口中使用的代码页是中文或者美国的,即 ...