[转][C#][Oracle]备份

// 获取所有存储过程 -- owner,
string sql = @"select object_name
from dba_objects
where object_type=‘PROCEDURE‘
and owner=‘DBO‘";

string sql2 = @"select text from user_source where name = :a and type=‘PROCEDURE‘";
IEnumerable<string> axs = conn.Query<string>(sql);

if(axs != null && axs.Count() > 0)
{
    foreach (var item in axs)
    {
        IEnumerable<string> proc = conn.Query<string>(sql2, new { 
            a = item
        });

        if(proc != null && proc.Count()>0)
        {
            var sw = File.CreateText(@"D:\" + item + ".sql");
            sw.Write(string.Join("", proc));
            sw.Close();
        }
    }
}

转自:https://blog.csdn.net/qq_30189805/article/details/99288790

转自:https://blog.csdn.net/huangbaokang/article/details/95446606

相关推荐