mysql=# update pg_class set oid = 99999 where oid=73728
ERROR: cannot assign to system column "oid"
LINE 1: update pg_class set oid = 99999 where oid=73728
但是我们可以将其删除
mysql=# delete from pg_class where oid=73728
DELETE 1
在postgresql中有一个copy命令,有一个参数 with oids,可以将oid一起导入,利用这个特性,我们可以达到oid的修改功能。
1.首先新建一个文件,将数据放入,新的oid已修改
[mysql@pttest4 cxf]$ cat 2.dat
73740|test|2200|73729|10|0|73740|0|0|0|0|0|f|f|r|1|0|0|0|0|0|f|f|f|f|814|/N|/N
2.使用copy命令导入数据
copy pg_class from '/home/mysql/cxf/2.dat' null as E'//N' csv delimiter '|' oids
3.修改其他表中的对应oid数据
update pg_attribute set attrelid ='73740' where attrelid ='73728'
update pg_depend set refobjid='73740' where refobjid ='73728'
update pg_type set typrelid ='73740' where typrelid = '73728'
ps:如果还涉及其他的数据字典,应一并修改掉
4.查询,可以看出oid已变更
mysql=# select * from test
ERROR: could not open relation 1663/16386/73740: No such file or directory
mysql=# select oid from pg_class where relname ='test'
oid
-------
73740
(1 row)
5.将数据文件更名为新的oid
[mysql@pttest4 16386]$ mv 73728 73740
再查数据库,原有的那条数据还是可以访问到的。
mysql=# select * from test
a
---
1
(1 row)
至此,oid修改成功。
修改oid引发的其他问题。由于当前系统的oid是73735,而我们变更的oid(73740)在这个之后,接着我们创建表的时候这个oid还会重用,这样有可能会造成oid错乱。如下
mysql=# create table helloworld(b varchar(1))
CREATE TABLE
mysql=# select oid from pg_class where relname='helloworld'
oid
-------
73735
(1 row)
mysql=# create table helloworld1(b varchar(1))
CREATE TABLE
mysql=# create table helloworld2(b varchar(1))
CREATE TABLE
mysql=# create table helloworld3(b varchar(1))
CREATE TABLE
mysql=# select oid from pg_class where relname like 'helloworld%'
oid
-------
73735
73737
73739
73741
(4 rows)
mysql=# select * from pg_type where oid = '73740'
typname | typnamespace | typowner | typlen | typbyval | typtype | typisdefined | typdelim | typrelid | typelem | typinput | typoutput | typreceive | typsend | typanalyze | typalign | typstorage | typnotnull | typbasetype | typtypmod | typndims | typdefaultbin | typdefault
-------------+--------------+----------+--------+----------+---------+--------------+----------+----------+---------+-----------+------------+-------------+-------------+------------+----------+------------+------------+-------------+-----------+----------+---------------+------------
helloworld2 | 2200 | 10 | -1 | f| c | t| ,|73739 | 0 | record_in | record_out | record_recv | record_send | - | d| x | f | 0 |-1 |0 | |
(1 row)
可以看到,新的pg_type的oid用到了73740。
为了避免这种情况,我们可以用pg_resetxlog重置oid。
如:pg_resetxlog -o 80000 ~/postgresql/data/
这样子建表的时候oid就重80000开始了,避免了刚刚那个问题。
大数据分析挖掘与处理、移动开发与架构、软件开发、云计算等前沿技术等。
主修课程:面向对象程序设计、Hadoop实用技术、数据挖掘、机器学习、数据统计分析、高等数学、Python编程、JAVA编程、数据库技术、Web开发、Linux *** 作系统、大数据平台搭建及运维、大数据应用开发、可视化设计与开发等。
旨在培养学生系统掌握数据管理及数据挖掘方法,成为具备大数据分析处理、数据仓库管理、大数据平台综合部署、大数据平台应用软件开发和数据产品的可视化展现与分析能力的高级专业大数据技术人才。
扩展资料:
越来越多的行业对大数据应用持乐观的态度,大数据或者相关数据分析解决方案的使用在互联网行业,比如百度、腾讯、淘宝、新浪等公司已经成为标准。而像电信、金融、能源这些传统行业,越来越多的用户开始尝试或者考虑怎么样使用大数据解决方案,来提升自己的业务水平。
在“大数据”背景之下,精通“大数据”的专业人才将成为企业最重要的业务角色,“大数据”从业人员薪酬持续增长,人才缺口巨大。
参考资料来源:百度百科-大数据技术与应用
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)