本文介绍了使用Java schemacrawler,为什么要扫描我的数据库中的每个表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用Java ,为什么要扫描我的数据库中的每个表?不应该只是扫描我在命令行上指定的数据库: -database = openfire ?
Using Java schemacrawler, why is it scanning every table in my database? Shouldn't it just be scanning the database I specified on the command line: -database=openfire ???
:: schemacrawler batch launcher
@echo off
C:\JDK\bin\java.exe -classpath jtds-1.2.4.jar;schemacrawler-8.8.jar; \
schemacrawler-sqlserver-8.8.jar schemacrawler.tools.sqlserver.Main \
-user=sa -password=password -database=openfire -port=1433 -host=localhost \
-table_types=TABLE -command=schema -schemas=.*\.dbo.* -infolevel=standard \
-loglevel=FINE
推荐答案
好吧,我想出来了。 -database标志只给予sql驱动程序一个连接路径,它不影响数据库名称的过滤器。换句话说:
Ok, I figured it out. The -database flag only gives the sql driver a connect path, it doesn't affect the filter for the database name. In other words:
-database=openfire DOES NOT EQUAL -schemas=openfire.dbo.*
因此,答案是:
:: schemacrawler batch launcher
@echo off
C:\JDK\bin\java.exe -classpath jtds-1.2.4.jar;schemacrawler-8.8.jar; \
schemacrawler-sqlserver-8.8.jar schemacrawler.tools.sqlserver.Main \
-user=sa -password=password -database=openfire -schemas=openfire.dbo.* \
-port=1433 -host=localhost -table_types=TABLE -command=schema \
-infolevel=standard -loglevel=FINE
我完成的批处理脚本:
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
:: first get timestamp of this script
SETLOCAL
FOR /F "skip=1 tokens=2-4 delims=(-)" %%a IN ('"echo.|date"') DO (
FOR /F "tokens=1-3 delims=/.- " %%A IN ("%DATE:* =%") DO (
SET %%a=%%A&SET %%b=%%B&SET %%c=%%C))
SET /A "yy=10000%yy% %%10000,mm=100%mm% %% 100,dd=100%dd% %% 100"
FOR /F "tokens=1-4 delims=:. " %%A IN ("%time: =0%") DO @SET \
UNIQUE=%yy%%mm%%dd%-%%A%%B
SET TITLE=Schema Crawler
TITLE=%TITLE%
:: supports DBNAME as argument
IF NOT "%1"=="" (
SET DBNAME=%1
C:\JDK\bin\java.exe -classpath jtds-1.2.4.jar;schemacrawler-8.8.jar; \
schemacrawler-sqlserver-8.8.jar schemacrawler.tools.sqlserver.Main -user=sa \
-password=password -database=!DBNAME! -schemas=!DBNAME!.dbo.* -port=1433 \
-host=localhost -table_types=TABLE -command=schema -procedures= \
-infolevel=lint -loglevel=OFF > !DBNAME!_schema_!UNIQUE!.txt
GOTO :END
)
:: run minimized
::IF NOT DEFINED PIL (
:: SET PIL=1
:: START /MIN "" %~0 %1
:: EXIT /B
::)
:: script start
ECHO Working...
OSQL.exe -E -Slocalhost -h-1 -Q"SET NOCOUNT ON;SELECT LTRIM(RTRIM(name)) \
FROM sysdatabases WHERE name NOT IN ('master','tempdb','model','msdb');" \
>dblist.txt
FOR /F "tokens=* delims= " %%I IN (dblist.txt) DO (
IF NOT "%%I"==" " (
SET DBNAME=%%I
SET DBNAME=!DBNAME: =!
ECHO !DBNAME!
C:\JDK\bin\java.exe -classpath jtds-1.2.4.jar;schemacrawler-8.8.jar; \
schemacrawler-sqlserver-8.8.jar schemacrawler.tools.sqlserver.Main -user=sa \
-password=password -database=!DBNAME! -schemas=!DBNAME!.dbo.* -port=1433 \
-host=localhost -table_types=TABLE -command=schema -procedures= \
-infolevel=lint -loglevel=OFF > !DBNAME!_schema_!UNIQUE!.txt
)
)
DEL /Q dblist.txt
GOTO :EXIT
:END
ECHO Finished processing %1 . Closing in 20 seconds...
ECHO.
FOR /l %%a in (20,-1,1) do (TITLE %TITLE% -- closing in %%as&ping \
-n 2 -w 1 127.0.0.1>NUL)
:EXIT
EXIT
这篇关于使用Java schemacrawler,为什么要扫描我的数据库中的每个表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!