gpt4 book ai didi

java - 使用 Java schemacrawler,为什么它要扫描我数据库中的每个表?

转载 作者:搜寻专家 更新时间:2023-10-30 21:53:15 25 4
gpt4 key购买 nike

使用 Java schemacrawler ,为什么它要扫描我数据库中的每个表?它不应该只是扫描我在命令行中指定的数据库:-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 驱动程序提供连接路径,它不影响数据库名称的过滤器。换句话说:

-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 - 使用 Java schemacrawler,为什么它要扫描我数据库中的每个表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7923424/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com