国开电大《数据库运维》实验四参考答案_第1页
国开电大《数据库运维》实验四参考答案_第2页
国开电大《数据库运维》实验四参考答案_第3页
国开电大《数据库运维》实验四参考答案_第4页
国开电大《数据库运维》实验四参考答案_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

2.实验内容

【实验5-1]使用o...outfile语句对数据库employees的表departments进行数据导

出。

的SQL•

Qu«ryS«rv«rTo“sScriptinc)Ulp

的的<T&d团困©.Qb

NavigMorSQLFrierSQLFite?SQLFilerSQlFiltSxSQLFite9*Adnwvstrat>on-DataExport

SCHEMAS

彳HfgROiB9•・51010M"*•,上♦QJbm

0Hterobjects1•0eeo^loyeesj

►age2•flhowtablesj

•SfLECT•FMMcaployees.departaentsIMTOOUTFXLE*D:/eaployees.departMnt

>Eschool

►Um

►test

AdrmfMstrtbcnSchemas

InfocmWoo

Noobjectselected

61110000USEemptoyew0rowfi)affeded0000tec

62110000tvwtables6row(B)rctuned0000wc/0>

G3110000SELKT'FROMemployeesdepvtmertiINTO093WReeledOOOOwc

Ob)ectInfoSession

【实验5-2]使用o...outfile语句对数据库employees的表salaries进行数据导出,

并使用fields字句指定字段值之间的符号分隔符为“二字段的包裹符号为

FileI4atVieD.Q&.”$«rverTMsScri>t>M)Ulp

的图击幻时用Ei£i®_@r

【实验5-3]使用mysqldump命令备份数据库中的某个表,对数据库employees的表

deparments导出SQL语句。

D:\MVSQL\nysql-8.0.17-winx64\bin>mysqldump-uroot-pemployeesdepartments>fiel

.sql

Enterpassword:MMMMMM

【实验5-4】使用mysqldump命令备份单个数据库,对数据库employees的导出SQL语句,

并忽略数据表departmentso

p:\MYSQL\mysql-8.。.17・3inx64\bin>ni9sqldunp-uroot-pemployees--ignor©-table=

mployees.departments>file2.sql

Enterpassword:xxxxxx

【实验5-5]使用mysqldump命令备份多个数据库,对数据库employees、test两个数据库导

出SQL语句。

D:\HVSQL\aysql-8.9.17-winx6tl\bin>Hysqldump-uroot-p--databases。叩loyeestest>fil»3.sql

Enterpassword:xxxxxx

【实验5-6]使用mysqldump命令导出界定格式文件数据,对数据库employees进行CSV文

件数据的导出。

0:\MVSOL\Bysql-8.0.17swinx64\bin>Bysqlduap-Jroot-peaplogees--tab:D:\aysqleaployees--fields-terainated-by

Enterpa$$Mord:

【实验5-7]使用图形化工具MySQLWorkbench导出数据库employees的表departments的

CSV格式数据。

MySQLWcxtbcnch

localimtanc<MfSOC

rileK4i1QueryS4rv«rT»UiS<ri|tiMKelp

ExportResults

FfeD:Vetnployeesjfepartments.csvwasexportedin0.200s

Exported9records

【实验5-8]使用图形化工具MySQLWorkbench导出数据库employees的表departments的

SQL文件。

令LocalnstanceMySQL

6DataExportAdvancedOpto,

ObjectSdectonJExportProgress

EnartCowpIrtMl

Status:

1of1exported.

LOO:

09:45:46(Xxnpngemployees(departments)

Runng:mysqMunp.exe--defoiits-fle-k:Vses^dnni-i^ppdata)k>cai\tenipMnipf)<F-host«tocatK>st-protocol-tcp-user-root-

column-«tatstcs-FALSE-port-3306--defaiJt-dwacter-«et«utft--skjp-triggers'emptoyees''departments,

09:45:46ExportofCzMJsersVkdnnstrator)PoajnentsVMnps^Pump20200610hasfrished

09:48:18Dumpngemployees(departments)

Rumng:mysqldinp.exe-defeiits-fie■*(:Vjsers\Bdmn~1^ppdataVocal\tefnp\trnpwdOrtz.cnf-host-tocatiost-protocol>tcp-user-root-

colum-statBtKSaFALSE-port"3306"defaiit-character-set-utfS--sngte-transaction-TRUE--siap-tnggers'employees,

09:48:19ExportofD:)PuTip20200610.sqlhasfinished

11:06:29Dunpvigemployees(departments)

Rumng:mysqlAfnp.exe-xiefaults-fie-*c:\Bers^dmn•■host^ocatKWt-protocol-top--user^oot-

cokmi-statstKS-FALSE-port-3306-defaiit-character

11:06:30txportofD:\(l)hasfnsbed

【实验5-9]使用DELETE语句删除employees数据库的表departments的表格数据,使用

LOADDATAINFILE语句,通过【实验异1】导出的文件,对删除的数据进行恢复,并使用

SELECT语句对恢复的数据进行检查。

D:\MVSQL\aysql-8.0.17-Hinx6H\bin>aysql-uroot-p

Enterpassword:MMMMMM

WelcoaototheMySQLMonitor.Coamandsendwith;or\g.

YourMySQLconnectionidis33

Serveru»rsion:8.0.17MySQLConmunitySeruer-GPL

Copyright(c)2600,2019.Oracleand/oritsaffiliates.Allrightsreserved.

OracleisaregisteredtrademarkofOracleCorporationand/orits

affiliates.Othernaaesnaybetradenarksoftheirrespective

owners

Typ®help;'or''h'forhelp.Type"\Ctocl«arth®currentinputstatoaont.

■ysql>useemployees

Dotabasochangvd

■ysql>deletefro«departnents;

QueryOK,9rowsaffected(5.55sec)

■ysql>loaddatainfile./.•/•./enployees_departmQnts.txt"intotabledepartments;

QueryOK,9rowsaffected(0.60sec)

Records:9Deleted:0Skipped:0Warnings:9

【实验5-10]使用DELETE语句删除employees数据的表salaries的表格数据,使用LOAD

DATAINFILE语句以及FIELDS子句,通过【实验5-2】导出的文件,对删除的数据进行恢

复,即字段值之间的符号分隔符为“二字段的包裹符号为

■ysql>deletefro«salaries;

QueryOK.2844647rowsaffected(1ain42.86sec)

■ysql>loaddatainfill/salaries.txt'*intotablesalariesfieldst«rainat«dby*,*•nclosedby

QueryOK.2844847rowsaffected(33.29s・c)

Records:28440476Skipped:8Warnings:0

【实验5-11]使用DELETE语句删除employees数据的表salaries的表格数据,使用

mysqlimport命令,通过【实验5-2】导出的文件,对删除的数据进行恢复,即字段值之间的

符号分隔符为“二字段的包裹符号为

I.\HYSQL\»y»ql-8.0.17-Minx€il\bin>Bysqlisport-uroot-pMploytts../../../Mlarits.txt

:nt・rp^ftttword;・■・■■・

■plo9we.“l・ri♦•:Records:GDeleted:GSkipped:9Uarnings:0

I:\NY$OL\»y”卜8.81?-MinxS^\bin>

【实验5-12】使用DROP命令employees数据库下的除departments的所有数据表及其数据,

使用mysql命令行工具,通过【实验51】导出的SQL文件恢复删除的数据。

《Type'help:'or*\h'forhelp.Type,\Ctoclearthecurrentinputstatenent.

nysql>use”ploy”s

Databasechanged

|Bysql>showtables:

ITabl•$.in_Qnploy99SI

Idepartaents

Idept_e・p

IdQpt.nanager

I。叩

Isalaries

Ititles

6rowsinset(6.0G8C)

■ysql>droptabledept.eap.dept.aandger.eaployees.salaries.titles:

QueryOK.Growsaffected(0.0?s«c)

■ysql>showtables:

ITables.in.enployeesI

Idepartments

1rowinset(6.00sec)

■yeql>quit

Bye

D:\HVSQL\aysql-8.6.17a-Ninx6ll\bin>Bysqlmroot-p9■ployM9<>>0:\HVSQL\aysql-8.0.1r-winxG4XbinXfile2.sql"

Enterpassword:MMMMMM

【实验5-13]使用DROP命令删除数据库employees和数据库test,使用SOURCE语句,

通过【实验5-5】导出的SQL文件恢复删除的数据。

mysql>dropdatabaseemployees;

QueryOK,6rowsaffected(6.03sec)

nysql>dropdatabasetest:

ERROR1008(HY0G9):Cantdropdatabasetest';databasedoesn'texist

hysql>sourceD:/MYSQL/nysql-8.0.1T-winxGH/bin/fil©3.sql;

QueryOK.0rowsaffected(G.00sec)

QueryOK,0rowsaffected(0.00sec)

QueryOK.0rowsaffected(6.60sec)

QueryOK,0rowsaffected(0.00sec)

JueryOK.erowsaffected(e.eesec)

)u©ryOK.erowsaffected(e.eesec)

OK.erowsaffected(e.ee8・C)

)upryOK.erowsaffected(e.eesee)

]upryOK.erow9affected(e.oosec)

OK.erowcaffected(e.eesec)

]ueryOK.erow©affected(e.eesec)

【实验5-14]删除数据库employees的表departments中的数据,使用图形化工具MySQL

Workbench,通过【实验5-7]恢复删除的数据。

【实验5-15]删除数据库employees的表departments及其数据,使用图形化工具MySQL

Workbench,通过【实验5-8】恢复删除的数据。

■yoql>droptabledept_emp;

QueryOK,0rowsaffected(0.01sec)

■ysql>droptabledepartments:

ERROR3730(HVGOG):Cannotdroptable'departments'referencGdbyaforeignkey

■ysql>droptabledept.manager:

QueryOK,0rowsaffected(0.01soc)

■ysql>droptabledepartments:

QueryOK,0rowsaffected(0.01sec)

SQLF4eVSQLFile2*SQLFileTSQLFile6*employees*SQLFieTAdrmmstrabon-DataImportRes.x

localnstanceMySQL

DataImport

InpatfromDakImportProgress

ImportCompleted

Status:

lof1vnported.

11:47:29Restomgemployees(departments)

Runrvng:mysql.exe・<efmjts・fite・・u3r$WdmrmppddtaWc*\tempMpSt>cvp.6g-protocoi-tcp-ho$t-kcrfx»t-user-root-

port-3306-defaJt-character-set-utffi-comments-database-enpioyees<T):\\(l)\V9nployeesjdepartYnents.sq|a

11:47:30ImportofD:\(l)hasfin$hed

【实验5-16]在时间点A使用m/sqldump命令对数据库employees导出SQL文件,进行逻

辑备份,备份完成,创建一个表test,并插入数据,在时间点B删除创建的表test,在时间

点C再次创建一个表test2,并插入一条数据。在这个操作过程中在时间点B删除表test是

误操作。使用mysqlbinlog进行基于时间点的恢复操作,即经过恢复之后employees数据库

中会同时存在数据表test2和数据表test0

■ysql>createtabletest(nameuarchar(1G).ageint);

QueryOK,0rowsaffected(9.00sec)

■ysql>insertintotest(nane.age)ualu。(,小明,,’29.);

QueryOK.1rowaffected(0.53sec)

■ysql>

I\MV$0L\«y«ql-801?-Minx^\0«t«baw>By9qlbinlo9lo9.bineoeees--start-position155--etop-po«ition731layeql-uroot-p

:nt»rpassword:"■■■■■

I\MVSX\B9«ql*S0.17-MInx€M\0atabA9t>By»ql-uroot,p

paeeworda・・・・・・

・lco“toCMHySQLaonitor.Coaoandsendwith.or\9

(ourMySQLconnectionidit51

4rutrvtreion:8817MySQLCoaaunityS^rvtr-GPL

Copyright(c)2GOG.201$.Oracleand/orit.effilieto.Allrifht,r・gruR

iracleio•r^ioteredtr»d«MrkofOracleCorporationand/orit«

Othernaaeouyb«tradeaarkoofth«irrespectiv»

an・9.

ypt'Mlp;"or'\h'forhelp.Typ・Ac,tocleerthtcurrentinput•tate»>nt.

iyeql>eeploy”

latabawchanged

ITabl”/n.”pl©y・”I

departMnte

•■ployws

“lari”

t”t2

titUo

r。“inMt(0.00B・C)

iyeql

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论