在从事软件开发的过程中,经常会涉及到在Linux下将数据库脚本文件从sh格式变为sql格式的问题。本文以一个实际的脚本文件为例,说明格式转换的过程。 1. sh文件内容 本文中的文件名为example.sh,其内容如下:#!/bin/bash function Init(){ if [ -f"example.sql" ] then echo"example.sql is exits and is deleting it,then recreate it" rm -fexample.sql else echo"example.sql no exits and is creating it" fi echo " usezxdbp_166 ">>example.sql echo " go">>example.sql} function CreateTable(){cat>>example.sql<< EOF create table tb_employeeinfo( employeeno varchar(20) not null, -- 员工工号 employeename varchar(20) not null, -- 员工姓名 employeeage int null -- 员工年龄);create unique index idx1_tb_employeeinfo ontb_employeeinfo(employeeno);create index idx2_tb_employeeinfo ontb_employeeinfo(employeename); print "create table tb_employeeinfo ok"go EOF} ## Execute functionInitCreateTable 说明: (1) 本文件用于创建tb_employeeinfo表,生成的脚本文件名为example.sql。 (2) Init函数用于在屏幕上输出信息,CreateTable函数用于创建数据表。 (3) 在sh文件的结尾,要按顺序将本文件所包含的所有函数罗列出来,如本文件包括的函数是Init和CreateTable。
更多详情见请继续阅读下一页的精彩内容: http://www.linuxidc.com/Linux/2014-07/104646p2.htm
【RMAN】使用duplicate本地复制数据库解决ORA-02395:超出I/O使用的调用限制问题相关资讯 Linux数据库脚本 本文评论 查看全部评论 (0)