因为服务器装了oracle 11G,本地装了oracle 10g,从服务器上导出的dmp文件在放到本地导入时,都显示:
IMP-00010:不是有效的导出文件,头部验证失败
后来在网上找了一哈资料,看到以下内容,下载下来试着修改了一下,还真可以导入了。
?
?
为了这个问题一直苦恼,差点就想卸掉11g然后装10g了,后来想想,头部验证,那么头部到底是什么,用Notepad++查看了dmp文件,发现头部真的显示一些东西:
11g R2:V11.02.00
11g R1:V11.01.00
10g:V10.02.01
把版本改成对方机子数据库版本,执行imp就不再报错了。
考虑到如果文件过大,可能打不开导致死机,做个小程序。(C# WINFORM)
2个按钮的事件:
private void button1_Click(object sender, EventArgs e)
??????? {
??????????? OpenFileDialog file = new OpenFileDialog();
??????????? file.InitialDirectory = Application.ExecutablePath;
??????????? if (file.ShowDialog() == DialogResult.OK)
??????????? {
??????????????? String path =label11.Text= file.FileName;
??????????????? FileStream fs = File.OpenRead(path);
??????????????? fs.Seek(0, SeekOrigin.Begin);
??????????????? byte[] byData = new byte[100];
??????????????? fs.Read(byData, 0, 50);
??????????????? string charData = new UTF8Encoding(true).GetString(byData, 0, byData.Length);
??????????????? string[] da = System.Text.RegularExpressions.Regex.Split(charData, @":V", RegexOptions.IgnoreCase);
??????????????? Regex r = new Regex(@":V\d{2}\.\d{2}\.\d{2}");
??????????????? Match m = r.Match(charData);
??????????????? label9.Text = m.Index.ToString ();
??????????????? label10.Text = m.Length.ToString();
??????????????? textBox1.Text = System.Text.RegularExpressions.Regex.Split(m.Value, @":V", RegexOptions.IgnoreCase)[1];
??????????????? fs.Close();
??????????? }
??????? }
??????? private void button2_Click(object sender, EventArgs e)
??????? {
??????????? Regex r = new Regex(@"\d{2}\.\d{2}\.\d{2}");
??????????? Match m = r.Match(textBox1.Text);
??????????? if (m.Success)
??????????? {
??????????????? FileStream fs = File.OpenWrite(label11.Text);
??????????????? fs.Seek(int.Parse(label9.Text.ToString())+2, SeekOrigin.Begin);
??????????????? Byte[] info = new UTF8Encoding(true).GetBytes(textBox1.Text);
??????????????? fs.Write(info, 0, info.Length);
? fs.Close();
??????????????? MessageBox.Show("版本修改成功。");
??????????? }
??????????? else
??????????????? MessageBox.Show("版本格式错误。");
??????? }
?
我已上传附件。大家可根据图片执行软件完成。