如何为oracle使用Bat文件excute dbms_stats

如何为oracle使用Bat文件excute dbms_stats,oracle,Oracle,我想执行一个批处理文件来执行命令,比如exec dbms\u stats.gather\u schema\u statsownname=>xxx',degree=>8,cascade=>true 首先,我编写了xx.sql文件并使用sqlplus运行,但它不起作用 第二,我像sqlplus xxx一样直接编写了批处理文件/xxx@xxdbms_stats.gather_schema_statsownname=>xxx',degree=>8,cascade=>true仍然没有运行 请帮助我如何执行

我想执行一个批处理文件来执行命令,比如exec dbms\u stats.gather\u schema\u statsownname=>xxx',degree=>8,cascade=>true

首先,我编写了xx.sql文件并使用sqlplus运行,但它不起作用

第二,我像sqlplus xxx一样直接编写了批处理文件/xxx@xxdbms_stats.gather_schema_statsownname=>xxx',degree=>8,cascade=>true仍然没有运行


请帮助我如何执行此sql。Thk ~

您可以编写如下内容:

xx.sql:

mybat.bat:

现在,双击mybat.bat文件执行它,您将看到以下输出:


干杯

你可以这样写:

xx.sql:

mybat.bat:

现在,双击mybat.bat文件执行它,您将看到以下输出:

干杯

begin
dbms_stats.gather_schema_stats(ownname=>'tejash',degree => 8,cascade =>true);
end;
/
exit;
@echo off 
sqlplus sys/oracle as sysdba @xx.sql
Echo Stats gathered successfully. 
echo Press any key to exit the script..
PAUSE >nul
SQL*Plus: Release 12.2.0.1.0 Production on Wed Dec 4 10:24:57 2019

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production


PL/SQL procedure successfully completed.

Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Stats gathered successfully.
Press any key to exit the script..