撞库攻击

黑客入门,爬虫技术,勒索软件,攻击软件,网络蜘蛛,网络病毒

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 function

  Init

  CreateTable

  表明:

  (1) 本文档用以建立tb_employeeinfo表,转化成的脚本文件名叫example.sql。

  (2) Init涵数用以在显示屏上輸出信息内容,CreateTable涵数用以建立数据分析表。

  (3) 在sh文件的末尾,要按序将本文档所包括的全部涵数列举出去,如本文档包含的涵数是Init和CreateTable。

  2. 转化成sql文件的全过程

  (1) 提交sh文件

  应用FTP工具(如filezilla)将example.sh文件上传入Linux的相匹配文件目录下。

  (2) 应用dos2unix指令改动格式文件

  因为example.sh文件是在当地的Windows电脑操作系统下撰写的,因而要先变换为Linux下的文件格式才可以应用。假如提交后立即应用,会发生“Permissiondenied”的出错信息内容。

  dos2unix指令用于将DOS文件格式的文本文档转化成UNIX文件格式的。其应用的文件格式为:dos2unix file,假如一次变换好几个文档,把这种文件夹名称立即跟在dos2unix以后(dos2unixfile1 file2 file3 …)。

  在这儿,指令实行以下:

  zhou@linux:~/sql> dos2unix example.sh

  dos2unix: converting file example.sh to UNIX format ...

  (3) 应用chmod指令改动文档的管理权限

  在实行了dos2unix指令以后,或是不可以立刻转化成文档,还必须改动文档的管理权限。

  chmod指令是Linux系统软件中最常见到的指令之一,用以更改文档或文件目录的访问限制。若要掌握相关该指令的其他信息,请网上查看。

  在这儿,指令为:chmod 777 example.sh

  (4) 转化成sql文件

  立即运作带后缀名的sh文件名,就可以转化成sql文件。指令以下:

  zhou@linux:~/sql> example.sh

  example.sql no exits and is creating it

  表明example.sql文件以前不会有,这是第一次转化成。

  再度运行命令:

  zhou@linux:~/sql> example.sh

  example.sql is exits and is deleting it,then recreate it

  表明example.sql文件早已存有了,如今删掉后再次转化成。

  3. sql文件內容

  转化成的sql文件名叫example.sql,文档內容以下:

  use zxdbp_166

  go

  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

  在具体的开发软件新项目中,混合开发实际操作是经常出现的事儿。作为一名达标的开发软件技术工程师,一定要灵活运用不一样电脑操作系统下的操作步骤及指令。

  • 评论列表:
  •  森槿倾酏
     发布于 2022-06-06 21:11:37  回复该评论
  • print 'create table tb_employeeinfo ok'  go  EOF  }  ## Execute function  Init  CreateTable  表明: 
  •  寻妄千纥
     发布于 2022-06-06 23:50:27  回复该评论
  •  }  ## Execute function  Init  CreateTable  表明:  (1) 本文档用以建立tb_employeeinfo表,转化成的脚本文件名叫example.sql。  (2)
  •  痛言梦息
     发布于 2022-06-06 16:46:55  回复该评论
  • varchar(20) not null, -- 职工名字  employeeage int null -- 职工年纪  );  create unique index idx1_tb_employeeinfo ontb_employeeinfo(employeen

发表评论:

Powered By

Copyright Your WebSite.Some Rights Reserved.