mysql 匯入資料到postgresql

2021-09-07 16:49:28 字數 3790 閱讀 3182

建立pg的表指令碼

drop table if exists "

public

"."t_resource_info";

create table

"public

"."t_resource_info"(

"area_code

" varchar(255) collate "

pg_catalog

"."default

"not null default null::character varying, "

id"int4 not null default null, "

resource_title

" varchar(1024) collate "

pg_catalog

"."default

"not null default null::character varying, "

resource_format

" varchar(16) collate "

pg_catalog

"."default

"not null default null::character varying, "

resource_size_int

"int8 not null default null, "

create_time

" timestamp(6

) not null default null::timestamp without time zone, "

down_count

" int4 not null default 0,

"file_id

"char(36) collate "

pg_catalog

"."default

"not null default null::bpchar, "

thumb_id

"char(36) collate "

pg_catalog

"."default

" not null default '1'

::bpchar, "

resource_type

"int4 not null default null, "

structure_id

"int4 not null default null, "

person_id

"int4 not null default null, "

identity_id

"int4 not null default null);

comment on column

"public

"."t_resource_info

"."area_code

" is '

地區碼'

;comment on column

"public

"."t_resource_info

"."id

" is '

地區中主鍵';

comment on column

"public

"."t_resource_info

"."resource_title

" is '

資源名稱';

comment on column

"public

"."t_resource_info

"."resource_format

" is '

資源格式';

comment on column

"public

"."t_resource_info

"."resource_size_int

" is '

資源尺寸';

comment on column

"public

"."t_resource_info

"."create_time

" is '

建立時間';

comment on column

"public

"."t_resource_info

"."down_count

" is '';

comment on column

"public

"."t_resource_info

"."file_id

" is '

檔案id';

comment on column

"public

"."t_resource_info

"."thumb_id

" is '

縮圖id';

comment on column

"public

"."t_resource_info

"."resource_type

" is '

資源型別';

comment on column

"public

"."t_resource_info

"."structure_id

" is '

所在的結構目錄';

comment on column

"public

"."t_resource_info

"."person_id

" is '

人員id';

comment on column

"public

"."t_resource_info

"."identity_id

" is '

人員身份id';

-- ----------------------------

-- primary key structure for

table t_resource_info

-- ----------------------------alter table

"public

"."t_resource_info

" add constraint "

t_resource_info_pkey

" primary key ("

id", "

area_code

");

-- 匯出檔案示例(mysql)

mysql -uroot -pd****** -ne "use dsideal_db; select 'kp' as area_code,id,resource_title,resource_format,resource_size_int,create_time,down_count,file_id,thumb_id,resource_type,structure_id,person_id,identity_id from t_resource_info limit 1000;" > /usr/local/mysql/t_resource_info.csv

-- 匯入csv(pg)

copy t_resource_info(area_code,id,resource_title,resource_format,resource_size_int,create_time,down_count,file_id,thumb_id,resource_type,structure_id,person_id,identity_id)

from 'd:\t_resource_info.csv'

感受一下效果:

SqlServer匯入資料到MySql

2.裝完後,新增odbc資料來源 3.在sqlserver management studio裡,選擇乙個資料庫,右鍵,然後匯出資料,在匯出目標那裡選擇.net framework data provider for odbc,配置好dsn為上一步建立的資料來源名稱,driver裡面填mysql o...

PHP Excel匯入資料到MySQL資料庫

我的模板內的資料如下圖 後端介面 如下 public function uplexcel request request 取陣列最後乙個元素,得到檔案型別 uploaddir uploads2 date y m d 設定檔案儲存目錄 注意包含 if file exists uploaddir pat...

postgresql資料匯入到mysql

使用pg dump命令匯出結構和資料。到postgresql安裝路徑的bin目錄下,使用 pg dump命令,pg dump dbname outfile 可選的引數有 h 伺服器位址,預設是本機,可省略 p 埠號 a data only 只輸出資料,不輸出結構 表定義 d column inser...