awk로 csv를 처리하려면.. 구분자를 , 로 하고 손을 봐야 하는데
영 매끄럽진 않네..
'Linux' 카테고리의 다른 글
screen 스크롤하기 (0) | 2019.09.23 |
---|---|
csv에서는 awk 보단 cut (0) | 2019.09.05 |
awk 변수 지정 (0) | 2019.09.02 |
awk 치환(삭제) (0) | 2019.09.02 |
tail과 cat 합치기 (0) | 2019.09.02 |
awk로 csv를 처리하려면.. 구분자를 , 로 하고 손을 봐야 하는데
영 매끄럽진 않네..
screen 스크롤하기 (0) | 2019.09.23 |
---|---|
csv에서는 awk 보단 cut (0) | 2019.09.05 |
awk 변수 지정 (0) | 2019.09.02 |
awk 치환(삭제) (0) | 2019.09.02 |
tail과 cat 합치기 (0) | 2019.09.02 |
9.0 이후 부터 unknown을 쓸수 없게 되었다는데 도대체 이런 타입을 어떻게 만든거지?
unknown became a pseudo-type with commit d8d32d9a5. Creation of tables with unknown columns was disabled in commit 1e7c4bb004. Both commits were in January 2017, long after 9.0 |
[링크 : https://dba.stackexchange.com/questions/241870/postgres-column-type-unknown/241872#241872]
일단은.. text로 바꾸어주면 되려나?
[링크 : https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=1e7c4bb...]
postgresql copy from csv , iso8859-1 (0) | 2019.09.05 |
---|---|
postgresql copy from csv, date null (0) | 2019.09.05 |
postgresql schema 내의 테이블 이동하기 (0) | 2019.09.05 |
pgadmin over ssh (0) | 2019.09.03 |
psql 명령어 (0) | 2019.09.03 |
스키마 자체를 변경해서 어떻게 할 수 있을줄 알았는데 그건 안되고
테이블에 해당 schema 정보가 있기 때문에
table 별로 이동을 시켜주어야 한다.
동일 데이터베이스내면 그나마 다행인데.. 그게 아니라면 pg_dump로 뺴내서 데이터베이스간에 옮겨야 한다.
[링크 : https://www.codeproject.com/Questions/1020013/how-to-copy-table-one-database-to-another-database]
[링크 : https://www.postgresql.org/docs/9.1/sql-altertable.html]
postgresql copy from csv, date null (0) | 2019.09.05 |
---|---|
postgresql unknown pseudo-type (0) | 2019.09.05 |
pgadmin over ssh (0) | 2019.09.03 |
psql 명령어 (0) | 2019.09.03 |
postgresql copy 와 \copy (0) | 2019.09.03 |
설정이 꼬였나.. 기존에는 바로 된거 같은데 안되네?
$ sudo vim /etc/apache2/apache2.conf Include /etc/phpmyadmin/apache.conf $ sudo service apache2 restart |
[링크 : https://tistory.woobi.org/52]
우분투 화상 키보드 끄기 (0) | 2019.12.21 |
---|---|
mx linux - xfce + debian (0) | 2019.10.14 |
ubuntu 18.04 wayland와 ubuntu session (0) | 2019.08.28 |
ubuntu virtual desktop (0) | 2019.08.28 |
ubuntu 18.04 fsck 예약(?) (0) | 2019.08.27 |
compatible을 넣는다고 해서 해당 compatible mode의 주석처리나 변수형이 바뀌진 않는다.. 인가?
Produce output that is more compatible with other database systems or with older MySQL servers. The value of name can be ansi, mysql323,mysql40, postgresql, oracle, mssql, db2, maxdb, no_key_options, no_table_options, or no_field_options. To use several values, separate them by commas. These values have the same meaning as the corresponding options for setting the server SQL mode. See Section 5.1.10, “Server SQL Modes”. This option does not guarantee compatibility with other servers. It only enables those SQL mode values that are currently available for making dump output more compatible. For example, --compatible=oracle does not map data types to Oracle types or use Oracle comment syntax. |
[링크 : https://dev.mysql.com/doc/refman/5.5/en/mysqldump.html]
[링크 : https://dev.mysql.com/doc/refman/5.5/en/sql-mode.html]
HeidiSQL (2) | 2021.08.18 |
---|---|
sql zerofill (0) | 2019.11.25 |
mysql / unix-socket (0) | 2019.09.04 |
mysql exists (0) | 2019.07.05 |
mysql timestamp 1분 이내 매치하기 (0) | 2018.12.21 |
그냥 root 권한은 유닉스 소켓으로 접속하게 되어있어서
sudo 를 통해 권한을 변경해서 접속하면 된다고... -_-
$ sudo mysql -u root |
[링크 : https://stackoverflow.com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost]
sql zerofill (0) | 2019.11.25 |
---|---|
mysql-dump compatible 함정 -_- (0) | 2019.09.04 |
mysql exists (0) | 2019.07.05 |
mysql timestamp 1분 이내 매치하기 (0) | 2018.12.21 |
mysql join과 필드명 변경하기 (0) | 2018.12.21 |
거창한건 아니고 리눅스에서 -L 옵션을 통해 ssh의 포트포워딩으로
localhost 포트를 통해 접속하는 것. 나름 속도도 잘나오고 좋네
[링크 : https://www.tecmint.com/create-ssh-tunneling-port-forwarding-in-linux/]
[링크 : https://www.linode.com/.../how-to-access-postgresql-database-remotely-using-pgadmin-on-windows/]
postgresql unknown pseudo-type (0) | 2019.09.05 |
---|---|
postgresql schema 내의 테이블 이동하기 (0) | 2019.09.05 |
psql 명령어 (0) | 2019.09.03 |
postgresql copy 와 \copy (0) | 2019.09.03 |
pg_restore (0) | 2019.09.03 |
\dt 밖에 기억을 못하고 살아서 좀더 봐야 할 듯
정보보기 \dy [PATTERN] 이벤트 트리거 목록 |
전체 스키마 목록
\dn
[링크 : https://tableplus.com/blog/2018/04/postgresql-how-to-list-all-schemas.html]
기본은 public schema만 보도록 되어있어서
show search_path;를 통해 현재 설정된 것을 보고
set search_path = newschema;를 통해서 newschema를 기본으로 보게 된다(\dt 등의 결과가 영향을 받음)
[링크 : https://www.mkyong.com/database/postgresql-how-to-change-default-schema/]
postgresql schema 내의 테이블 이동하기 (0) | 2019.09.05 |
---|---|
pgadmin over ssh (0) | 2019.09.03 |
postgresql copy 와 \copy (0) | 2019.09.03 |
pg_restore (0) | 2019.09.03 |
postgresql working directory (0) | 2019.09.02 |
copy는 SQL 문의 명령어 이고
[링크 : https://www.postgresql.org/docs/9.2/sql-copy.html]
\copy는 psql에서 인식하는 meta command 라고..
pgadmin over ssh (0) | 2019.09.03 |
---|---|
psql 명령어 (0) | 2019.09.03 |
pg_restore (0) | 2019.09.03 |
postgresql working directory (0) | 2019.09.02 |
postgresql \copy에서 컬럼 무시하기 (0) | 2019.09.02 |
원하는 내용만을 빼낼수는 있는 듯?
그나저나.. 특정 schema에 넣으려고 했는데 왜 안되지.. ㅠㅠ
[링크 : http://i5on9i.blogspot.com/2016/09/db-pgdump-pgrestore.html]
[링크 : https://www.postgresql.org/docs/9.2/app-pgrestore.html]
[링크 : https://stackoverflow.com/questions/4191653/i-want-to-restore-the-database-with-a-different-schema]
옵션을 봐도.. schema만 복구하는 등의 옵션은 있지만
특정 스키마로 복구하는 옵션은 존재하지 않는듯.
하고 나서 alter 로 변경해야 할것으로 보인다.
$ pg_restore --help pg_restore 프로그램은 pg_dump로 만들어진 자료파일로 PostgreSQL 데이터베이스에 그 자료를 일괄 입력합니다. 사용법: pg_restore [옵션]... [파일] 일반 옵션들: -d, --dbname=NAME 접속할 데이터베이스 이름 -f, --file=FILENAME 출력 파일 이름 -F, --format=c|d|t 백업 파일 형식 (지정하지 않으면 자동분석) -l, --list 자료의 요약된 목차를 보여줌 -v, --verbose 자세한 정보 보여줌 -V, --version 버전 정보를 보여주고 마침 -?, --help 이 도움말을 보여주고 마침 리스토어 처리를 위한 옵션들: -a, --data-only 스키마는 빼고 자료만 입력함 -c, --clean 다시 만들기 전에 데이터베이스 개체 지우기(삭제) -C, --create 작업 대상 데이터베이스를 만듦 -e, --exit-on-error 오류가 생기면 끝냄, 기본은 계속 진행함 -I, --index=NAME 지정한 인덱스 만듦 -j, --jobs=NUM 여러 병렬 작업을 사용하여 복원 -L, --use-list=FILENAME 출력을 선택하고 해당 순서를 지정하기 위해 이 파일의 목차 사용 -n, --schema=NAME 해당 스키마의 개체들만 복원함 -N, --exclude-schema=NAME 해당 스키마의 개체들은 복원 안함 -O, --no-owner 개체 소유권 복원 건너뛰기 -P, --function=NAME(args) 지정한 함수 만듦 -s, --schema-only 자료구조(스키마)만 만듦 -S, --superuser=NAME 트리거를 사용하지 않기 위해 사용할 슈퍼유저 사용자 이름 -t, --table=NAME 복원할 객체 이름 (테이블, 뷰, 기타) -T, --trigger=NAME 지정한 트리거 만듦 -x, --no-privileges 접근 권한(grant/revoke) 지정 안함 -1, --single-transaction 하나의 트랜잭션 작업으로 복원함 --disable-triggers 자료만 복원할 때 트리거 사용을 안함 --enable-row-security 로우 보안 활성화 --if-exists 객체 삭제 시 IF EXISTS 구문 사용 --no-comments 코멘트는 복원하지 않음 --no-data-for-failed-tables 만들 수 없는 테이블에 대해서는 자료를 덤프하지 않음 --no-publications 발행 정보는 복원 안함 --no-security-labels 보안 라벨을 복원하지 않음 --no-subscriptions 구독 정보는 복원 안함 --no-tablespaces 테이블스페이스 할당을 복원하지 않음 --section=SECTION 지정한 섹션만 복원함 섹션 종류: pre-data, data, post-data --strict-names 테이블이나 스키마를 지정했을 때 그 패턴에 맞는 객체가 적어도 하나 이상 있어야 함 --use-set-session-authorization SET SESSION AUTHORIZATION 명령을 ALTER OWNER 명령 대신 사용하여 소유권 설정 연결 옵션들: -h, --host=HOSTNAME 접속할 데이터베이스 서버 또는 소켓 디렉터리 -p, --port=PORT 데이터베이스 서버의 포트 번호 -U, --username=NAME 연결할 데이터베이스 사용자 -w, --no-password 암호 프롬프트 표시 안 함 -W, --password 암호 입력 프롬프트 보임(자동으로 처리함) --role=ROLENAME 복원 전에 SET ROLE 수행 The options -I, -n, -N, -P, -t, -T, and --section can be combined and specified multiple times to select multiple objects. 사용할 입력 파일을 지정하지 않았다면, 표준 입력(stdin)을 사용합니다. 오류보고: <pgsql-bugs@postgresql.org>. |
결론은.. WAL을 활성화 시키고 그걸 쓰면 최대한 올릴수 잇고
8.4 이후 부터 병렬처리 옵션을 지원하니 그걸 쓰라고.. (일단은 하드불이 안꺼지는거 봐서는 WAL이 좀더 도움이 될 듯..)
First check that you are getting reasonable IO performance from your disk setup. Then check that you PostgreSQL installation is appropriately tuned. In particular shared_buffers should be set correctly, maintenance_work_mem should be increased during the restore, full_page_writes should be off during the restore, wal_buffers should be increased to 16MB during the restore, checkpoint_segments should be increased to something like 16 during the restore, you shouldn't have any unreasonable logging on (like logging every statement executed), auto_vacuum should be disabled during the restore. If you are on 8.4 also experiment with parallel restore, the --jobs option for pg_restore. |
[링크 : https://stackoverflow.com/questions/2094963/postgresql-improving-pg-dump-pg-restore-performance]
+
위의 옵션들을 건드리고 -j 4 로 해서 수행하니 40분 걸렸네..
938M 8월 1 15:48 postgres_data.dmp
938MB.. 정상 속도인건가? 아무튼 SSHD라 어느정도 넘어가면 HDD 속도에 늦어져서 그럴지도
real 39m28.317s user 0m36.639s sys 0m2.967s |
+
SQL dump는 이렇게 빨리 되네.. -_-
(용량이 위는 900MB 아래는 500MB 지만)
real 2m55.319s user 0m1.206s sys 0m0.573s |
+
--------+----------------------------+--------+----------+------------+------ ctgov | baseline_counts | 테이블 | postgres | 8072 kB | ctgov | baseline_measurements | 테이블 | postgres | 159 MB | ctgov | brief_summaries | 테이블 | postgres | 200 MB | ctgov | browse_conditions | 테이블 | postgres | 45 MB | ctgov | browse_interventions | 테이블 | postgres | 24 MB | ctgov | calculated_values | 테이블 | postgres | 29 MB | ctgov | central_contacts | 테이블 | postgres | 13 MB | ctgov | conditions | 테이블 | postgres | 45 MB | ctgov | countries | 테이블 | postgres | 24 MB | ctgov | criteria | 테이블 | postgres | 8192 bytes | ctgov | design_group_interventions | 테이블 | postgres | 34 MB | ctgov | design_groups | 테이블 | postgres | 114 MB | ctgov | design_outcomes | 테이블 | postgres | 451 MB | ctgov | designs | 테이블 | postgres | 37 MB | ctgov | detailed_descriptions | 테이블 | postgres | 301 MB | ctgov | documents | 테이블 | postgres | 2096 kB | ctgov | drop_withdrawals | 테이블 | postgres | 26 MB | ctgov | eligibilities | 테이블 | postgres | 407 MB | ctgov | facilities | 테이블 | postgres | 241 MB | ctgov | facility_contacts | 테이블 | postgres | 28 MB | ctgov | facility_investigators | 테이블 | postgres | 17 MB | ctgov | id_information | 테이블 | postgres | 30 MB | ctgov | intervention_other_names | 테이블 | postgres | 18 MB | ctgov | interventions | 테이블 | postgres | 103 MB | ctgov | ipd_information_types | 테이블 | postgres | 856 kB | ctgov | keywords | 테이블 | postgres | 71 MB | ctgov | links | 테이블 | postgres | 7824 kB | ctgov | mesh_headings | 테이블 | postgres | 1128 kB | ctgov | mesh_terms | 테이블 | postgres | 5920 kB | ctgov | milestones | 테이블 | postgres | 34 MB | ctgov | outcome_analyses | 테이블 | postgres | 50 MB | ctgov | outcome_analysis_groups | 테이블 | postgres | 18 MB | ctgov | outcome_counts | 테이블 | postgres | 55 MB | ctgov | outcome_measurements | 테이블 | postgres | 1291 MB | ctgov | outcomes | 테이블 | postgres | 178 MB | ctgov | overall_officials | 테이블 | postgres | 38 MB | ctgov | participant_flows | 테이블 | postgres | 7984 kB | ctgov | pending_results | 테이블 | postgres | 1712 kB | ctgov | provided_documents | 테이블 | postgres | 1480 kB | ctgov | reported_events | 테이블 | postgres | 1787 MB | ctgov | responsible_parties | 테이블 | postgres | 26 MB | ctgov | result_agreements | 테이블 | postgres | 15 MB | ctgov | result_contacts | 테이블 | postgres | 5120 kB | ctgov | result_groups | 테이블 | postgres | 273 MB | ctgov | sponsors | 테이블 | postgres | 44 MB | ctgov | studies | 테이블 | postgres | 186 MB | ctgov | study_references | 테이블 | postgres | 128 MB | |
psql 명령어 (0) | 2019.09.03 |
---|---|
postgresql copy 와 \copy (0) | 2019.09.03 |
postgresql working directory (0) | 2019.09.02 |
postgresql \copy에서 컬럼 무시하기 (0) | 2019.09.02 |
postgresql \copy에서 시작 몇줄 무시하기 (0) | 2019.09.02 |