2ã¤ã®ã¹ãã¼ãã«ä½æããã¦ãããã¼ãã«ã®å®ç¾©ãç°ãªã£ã¦ãªãã確èªãããã£ãã®ã§ãdescã³ãã³ãã®çµæããã¡ã¤ã«åºåããã¹ã¯ãªãããä½æãã¦ã¿ã¾ããã
åã«Oracleã¨PowerShellã®ãã¤ãã©ã¤ã³ã¨ãã¢ããã¥ã¡ã³ããã¹ããï¼ - ãªãæ¥è¨ã§æ¸ããäºã使ã£ã¦ã¿ããã£ãã ãã¨ãã話ãããã¾ããã»ã»ã»
ã¹ãã¼ãæ¯ã«ãã©ã«ããä½æããã®ã§ããã®ãã©ã«ããã¨æ¯è¼ãã¦ãããã°çæ¹ã«ããåå¨ããªããã¼ãã«ãåå¨ãããã©å®ç¾©ãç°ãªããã¼ãã«ã確èªã§ããã¨ããæãã§ãã
ã¡ãªã¿ã«ãODP.Netåã³ãSQL*Plusã使ããï¼OracleClientãã¤ã³ã¹ãã¼ã«ããã¦ããï¼ç°å¢ãããªãã¨åãã¾ããã
# Oracleã®å®ç¾©ï¼descã®çµæï¼ããã¼ãã«åä½ã«ãã¡ã¤ã«åºåãã # åºåå ï¼ã«ã¬ã³ããã£ã¬ã¯ããªã«ãå ¥åããã[ã¦ã¼ã¶ID]ãã§ãã£ã¬ã¯ããªãä½æãã¦åºåãã [System.Reflection.Assembly]::LoadWithPartialName("Oracle.DataAccess") | Out-Null function GetUserTables { param($uid, $pass, $svc) $connstr = "User ID=$uid;Password=$pass;Data Source=$svc" $conn = New-Object Oracle.DataAccess.Client.OracleConnection($connstr) $conn.Open() $cmd = New-Object Oracle.DataAccess.Client.OracleCommand $cmd.Connection = $conn $cmd.CommandText = "select TABLE_NAME from USER_TABLES order by TABLE_NAME" $reader = $cmd.ExecuteReader() while ($reader.Read()) { $reader[0].ToString() } } function OutputDefiniton { param($uid, $pass, $svc, $talbes) if (!(Test-Path $uid)) { mkdir $uid | Out-Null } $talbes | %{ $tableName=$_ "spool $uid\${tableName}.def" "desc $tableName" "spool off" } | sqlplus -S $uid/$pass@$svc | Out-Null } $uid = Read-Host "UserID:" $pass = Read-Host "Password:" $svc = Read-Host "ServiceName:" $talbes = GetUserTables $uid $pass $svc OutputDefiniton $uid $pass $svc $talbes
USER_TABLESãåç §ãã¦ãã¼ãã«ã®ä¸è¦§ãåå¾ãããã¼ãã«åä½ã«descã³ãã³ãã®çµæããã¡ã¤ã«ã«åºåãã¦ãã¾ãããã¡ã¤ã«åºåã¯SQL*Plusã®spoolæ©è½ã«ä¸¸æãã
SQL*Plus使ããã«ãUSER_TAB_COLUMNSãåç §ãã¦åãã¼ãã«ã®é ç®å®ç¾©ãåºåããã¨ããæ¹æ³ãããã¾ãããç®çãæºãããä¸çªæ¥½ãªæ¹æ³ã§çä»ãã¡ããã¾ããã
ããã«ãã¦ããPowerShellã®ã·ã³ã¿ãã¯ã¹ãã¤ã©ã¤ãã¯ã¾ã ã§ãããï¼