データベースを用いた統計表の編集の ... - Stat · Ⅶ データベースを用いた統計表の編集のしかた. 1 データベースについて (1) データベースは,政府統計の総合窓口(
Amazon Redshift - データベース開発者ガイド · Amazon Redshift...
Transcript of Amazon Redshift - データベース開発者ガイド · Amazon Redshift...
-
Amazon Redshift
-
Amazon Redshift
Amazon Redshift: Copyright 2019 Amazon Web Services, Inc. and/or its affiliates. All rights reserved.
Amazon's trademarks and trade dress may not be used in connection with any product or service that is not Amazon's,in any manner that is likely to cause confusion among customers, or in any manner that disparages or discreditsAmazon. All other trademarks not owned by Amazon are the property of their respective owners, who may or may notbe affiliated with, connected to, or sponsored by Amazon.
-
Amazon Redshift
Table of Contents ............................................................................................................................................ 1
Amazon Redshift ...................................................................... 1 ..................................................................................................... 2 .................................................................................................................................... 3
Amazon Redshift .......................................................................................................... 4 ............................................................................... 4 .......................................................................................................................... 6
....................................................................................................................... 6 ..................................................................................................... 7 ....................................................................................................................... 7 ......................................................................................................... 7 .............................................................................................................. 7 ......................................................................................................... 8
....................................................................................................................... 8 ............................................................................................. 10 ...................................................................................................................... 11 Amazon Redshift ................................................................................ 11
Amazon Redshift Amazon S3 ............................................................. 11Amazon Redshift Amazon DynamoDB ............................................................. 11SSH ........................................................... 12AWS Data Pipeline .......................................................... 12AWS Database Migration Service (AWS DMS) .................................... 12
.................................................................................................................... 13 1: ........................................................................................... 13 2: ............................................................................... 14
........................................................................................ 14 3: ............................................................................... 14
........................................................................................... 15 ........................................................................................... 15
4: ..................................................................................... 16 5: .................................................................................. 16
........................................................................................... 16 ........................................................................................ 17 .................................................................................................... 17 ID ................................................................................ 18
6: ........................................................................................... 18 ......................................................................... 19Superuser ................................................................ 20
7: .................................................................................. 20PoC () ...................................................................................................................... 21
PoC () ..................................................................................................... 21PoC () .............................................................................................................. 21
.................................................................................................... 21 .................................................................................. 22
................................................................................................ 22Amazon Redshift .......................................................................................... 23Amazon Redshift .......................................................................................... 24 ...................................................................................................................... 25
Amazon Redshift ............................................................................................... 26 ............................................................................................. 26
............................................................ 27 .................................................................................................... 27 ................................................................................................. 27 ................................................................................................................. 28
iii
-
Amazon Redshift
....................................................................................................................... 28 .......................................................................................................... 29 ........................................................................................... 29
............................................................................................. 29 ............................................................................... 29 ............................................................ 30COPY ........................................................................... 30 COPY ............................................................................................ 30 ............................................................................... 30 ........................................................................................... 30 .............................................................................................. 31 ......................................................................... 31 .......................................................................................................... 31 ................................................................................................................. 31 ..................................................................................... 31 ........................................................................................ 32 ....................................................................................................... 32 ...................................................................... 32 ...................................................................... 33
............................................................................................. 33Advisor ......................................................................................................................... 34
....................................................................................................... 35Advisor ........................................................................................................... 36
: ....................................................................................... 47 .................................................................................................................................. 47 .................................................................................................................................. 47 1: .................................................................................. 47
..................................................................................... 48 .................................................................................................................... 51
2: ................................................................................................. 51 .......................................... 52 .................................................................................................................... 54
3: .............................................................................................. 55 ................................................................................................. 55 .................................................................................................................... 55
4: ........................................................................................... 56 .................................................................................................................... 56 .............................................................................................. 57 .................................................................................................................... 59
5: ........................................................................................ 59 ........................................................................................... 59 .................................................................................................................... 62
6: ............................................................................... 62 .................................................................................. 62 .................................................................................................................... 65
7: .............................................. 65 ................................................ 65 .................................................................................................................... 69
8: ....................................................................................................... 69 .................................................................................................................... 70
9: .................................................................................. 70 .................................................................................................................... 70
........................................................................................................................................ 70 .................................................................................................................... 71
: Amazon S3 ............................................................................ 72 .................................................................................................................................. 72 ........................................................................................................................................ 72
iv
-
Amazon Redshift
.................................................................................................................................. 73 1: .............................................................................................. 73
.................................................................................................................... 74 2: ............................................................................ 74
.................................................................................................................... 75 3: Amazon S3 ..................................................... 75
...................................................................................................................................... 75 .................................................................................................................... 76
4: ..................................................................................... 76 .................................................................................................................... 78
5: COPY ........................................................................................ 79COPY ....................................................................................................... 79SSB ...................................................................................................... 80
6: ....................................................... 91 .................................................................................................................... 91
7: .................................................................................. 91 ................................................................................................................................... 91
........................................................................................................................................ 91 .................................................................................................................... 92
: WLM ............................................................................................. 93 ........................................................................................................................................ 93
.......................................................................................................................... 93 ....................................................................................................................... 93
1: ......................................................................... 93 1: WLM_QUEUE_STATE_VW ...................................................... 94 2: WLM_QUERY_STATE_VW ...................................................... 95 3: ................................................................................... 96
2: WLM ............................................................................. 97 1: .......................................................................... 97 2: WLM ............................................................................................. 98 3: ..................................................... 98
3: ............. 100 1: ...................................................... 101 2: ................................................ 101 3: ...................................................... 102 4: ............................................. 103
4: wlm_query_slot_count ................... 104 1: wlm_query_slot_count .................... 104 2: ............................................................... 105
5: ................................................................................... 106: Amazon Redshift Spectrum ......................................... 107
...................................................................................................................................... 107 ........................................................................................................................ 107
1: .............................................................. 108 2: SQL Amazon S3 ......................... 108
1: Structs ......................................................................................... 109 2: FROM ............................................................................................. 109 3: Scalars .......................................... 111 4: Maps ........................................................................................ 111
..................................................................................................... 112 ................................................................................................... 112 ......................................................................... 112Amazon Redshift ............................................................................ 113
................................................................................................................. 114 ...................................................................................................... 115
Amazon Redshift ........................................................................................ 115 ..................................................................................... 116
v
-
Amazon Redshift
.................................................................................................................... 116 ................................................................................................................................ 117
................................................................................... 117 ................................................................................................................................ 118
................................................................................... 118 ................................................................................................................................ 118
................................................................................... 119 ........................................................................................................................ 119 ...................................................................................................... 119
......................................................................... 120 ............................................................................................................................... 122
................................................................................................................. 122 ............................................................................................................... 123 ................................................................................................... 129: CUSTOMER ............................................................... 131
........................................................................................................ 132 ............................................................................................................ 133 .................................................................................................................. 134 ......................................................................................................... 135 ...................................................................................................... 135 ......................................................................................................... 136 ......................................................................................................... 137 ............................................................................................................ 138 ........................................................................................................................ 142
.................................................................................................................... 144 ............................................................................................................... 145 ................................................................................................ 145 ............................................................................................................ 146
............................................................................................................................. 149 ................................................................................................................. 150
Amazon Redshift Spectrum .................................................... 152Amazon Redshift Spectrum ............................................................................................ 152
Amazon Redshift Spectrum ........................................................................... 153Amazon Redshift Spectrum ..................................................................... 153
Amazon Redshift Spectrum ...................................................................................... 154 ........................................................................................................................ 154 ........................................................................................................................ 154 1.IAM ............................................................................... 155 2: IAM ............................................................... 157 3: ............................................................ 158 4: Amazon S3 ........................................................... 159
Amazon Redshift Spectrum IAM ............................................................................ 161Amazon S3 ................................................................................................. 161 Amazon S3 ....................................................................... 162Redshift Spectrum ................................. 162 ................................................................................................ 163IAM ........................................................................................................... 164AWS Glue ......................................................................................... 165
Lake Formation Redshift Spectrum ........................................................................ 170Amazon Redshift Spectrum ............................................... 171 ................................................................................................................. 173
......................................................................................................... 174 ................................................................................................................. 179
........................................................................................................................... 180Redshift Spectrum ............................................................ 181ORC .................................................................................................... 184
Amazon Redshift Spectrum .............................................................. 186
vi
-
Amazon Redshift
........................................................................................................ 189 .............................................................................................. 189
............................................................................................................... 189 .............................................................. 190 ..................................................................................................................... 190 ................................................................................................ 190Amazon Redshift DDL Hive ..................................................... 191 ................................................................................ 191
............................................................................................................................... 192COPY .............................................................................. 192
................................................................................................... 193 ...................................................................................................... 194Amazon S3 ................................................................................. 195Amazon EMR .............................................................................. 204 ............................................................................. 208Amazon DynamoDB .................................................................................. 214 ....................................................................... 217 ...................................................................................................... 217 ........................................................................................................................ 218 ......................................................................................... 220 .................................................................................................................. 220 ................................................................................................... 220
DML ..................................................................................................................... 225 ............................................................................................................................. 225
1: .................................................................................. 225 2: ..................................................................................... 226 .............................................................. 226 ....................................................................... 226 .......................................................................... 227 ..................................................................................................................... 228
........................................................................................................ 230 ................................................................................................................. 232
......................................................................................................... 232 ............................................................................................. 232ANALYZE ................................................................................................... 236
........................................................................................................ 237VACUUM ............................................................................................................. 237 ...................................................................................... 238 ...................................................................................................... 238 ............................................................................................................ 238 ................................................................................................ 239
..................................................................................................... 245 ............................................................................................................... 246/ ............................................................................... 248 ............................................................................................................ 249
......................................................................................................................... 251 Amazon S3 ..................................................................................... 251 ............................................................................ 254 .......................................................... 255 ........................................................................................ 256
................................................................................................................... 258UDF ................................................................................................ 258 SQL UDF ....................................................................................................... 259
SQL ................................................................................................... 259 Python UDF .................................................................................................... 259
Python UDF ............................................................................................... 260Python UDF ...................................................................................................... 260
vii
-
Amazon Redshift
ANYELEMENT .................................................................................................. 261Python .................................................................................................... 261UDF .................................................................................................................... 264
UDF ............................................................................................................................ 265 ............................................................................................................ 265UDF ....................................................................................................... 265
..................................................................................................... 265 ............................................................................................................. 267
..................................................................................................... 267 ...................................................................................... 269 ................................................................. 270 ............................................................................................................ 271 ................................................................................................... 272 ............................................................................................................ 277 ...................................................................................... 277 ..................................................................................................................... 278
PL/pgSQL ..................................................................................................... 278PL/pgSQL .......................................................................................... 279PL/pgSQL ............................................................................................................ 279 PL/pgSQL ................................................................... 283
................................................................................................ 294 ............................................................................................................................. 294
...................................................................................... 294 ............................................................................................. 296 .................................................................................................................. 297 .......................................................................... 303
........................................................................................................... 304 ................................................................................................... 304 ...................................................................................................... 305 ......................................................................................................... 306 ......................................................................................................... 307 ............................................................................................. 312 ................................................................................................ 314
.............................................................................................. 317 .................................................................................................................. 318 ......................................................................................................... 318 ............................................................................................. 319 ............................................................................................................ 320 ............................................................................................. 320 ................................................................................................ 321JDBC ............................................................................. 321
................................................................................................................... 322WLM ..................................................................................................................... 323
WLM WLM ................................................................................ 323 WLM .............................................................................................................................. 324
........................................................................................................................... 325 ............................................................................................. 325 ............................................................................................................ 325 ............................................................................................................... 325 ............................................................................................................... 326 ............................................................................................. 326 WLM ............................................................................................ 326 .................................................................................................................. 326
WLM .............................................................................................................................. 330 ............................................................................................. 331 ............................................................................................................... 331 ............................................................................................................ 332
viii
-
Amazon Redshift
............................................................................................................... 332 ............................................................................................................... 332 WLM ............................................................................................ 332WLM .......................................................................................................... 333 ............................................................................................. 333WLM ....................................................................................... 333
.............................................................................................................. 336 ...................................................................................... 336 ............................................................................................. 336 ................................................................................... 327 ................................................................................ 337 ............................................................................................................... 337
........................................................................................... 338SQA ....................................................................................................... 338SQA ....................................................................................................... 339
WLM ..................................................................................................... 339 ......................................................................................................... 340
..................................................................................................... 342 ........................................................ 342 ................................................................................ 342Superuser ............................................................................. 342
.............................................................................................. 343WLM .......................................................................................... 344 WLM ........................................................................................................... 344
..................................................................................................... 346 ...................................................................................... 346 ......................................................................................... 348 ............................................................................. 349 ..................................................... 350
WLM ............................................................................................... 351WLM ID .................................................................................................. 352
SQL ........................................................................................................................... 353Amazon Redshift SQL ............................................................................................................. 353
SQL ........................................................................ 353Amazon Redshift PostgreSQL ................................................................................. 354
SQL ............................................................................................................................ 359SQL ................................................................................................. 360 ..................................................................................................................... 360 ................................................................................................................................. 384 .............................................................................................................................. 387
SQL ......................................................................................................................... 404ABORT .......................................................................................................................... 406ALTER DATABASE ......................................................................................................... 407ALTER DEFAULT PRIVILEGES ........................................................................................ 409ALTER GROUP .............................................................................................................. 411ALTER PROCEDURE ...................................................................................................... 412ALTER SCHEMA ............................................................................................................ 413ALTER TABLE ................................................................................................................ 414ALTER TABLE APPEND .................................................................................................. 424ALTER USER ................................................................................................................. 427ANALYZE ...................................................................................................................... 431ANALYZE COMPRESSION .............................................................................................. 433BEGIN ........................................................................................................................... 435CALL ............................................................................................................................. 436CANCEL ........................................................................................................................ 438CLOSE .......................................................................................................................... 440COMMENT ..................................................................................................................... 440
ix
-
Amazon Redshift
COMMIT ........................................................................................................................ 442COPY ............................................................................................................................ 443CREATE DATABASE ...................................................................................................... 502CREATE EXTERNAL SCHEMA ........................................................................................ 503CREATE EXTERNAL TABLE ............................................................................................ 506CREATE FUNCTION ....................................................................................................... 518CREATE GROUP ............................................................................................................ 522 ...................................................................................................... 523CREATE PROCEDURE ................................................................................................... 525CREATE SCHEMA .......................................................................................................... 528CREATE TABLE ............................................................................................................. 529CREATE TABLE AS ........................................................................................................ 541CREATE USER .............................................................................................................. 549CREATE VIEW ............................................................................................................... 552DEALLOCATE ................................................................................................................ 555DECLARE ...................................................................................................................... 555DELETE ........................................................................................................................ 558DROP DATABASE .......................................................................................................... 559DROP FUNCTION ........................................................................................................... 560DROP GROUP ............................................................................................................... 561 ...................................................................................................... 562DROP PROCEDURE ....................................................................................................... 562DROP SCHEMA ............................................................................................................. 563DROP TABLE ................................................................................................................. 564DROP USER .................................................................................................................. 567DROP VIEW .................................................................................................................. 568END .............................................................................................................................. 569EXECUTE ...................................................................................................................... 570EXPLAIN ....................................................................................................................... 571FETCH .......................................................................................................................... 575GRANT .......................................................................................................................... 576INSERT ......................................................................................................................... 582LOCK ............................................................................................................................ 586PREPARE ...................................................................................................................... 587RESET .......................................................................................................................... 589REVOKE ........................................................................................................................ 589ROLLBACK .................................................................................................................... 595SELECT ........................................................................................................................ 596SELECT INTO ................................................................................................................ 624SET .............................................................................................................................. 624SET SESSION AUTHORIZATION ...................................................................................... 627SET SESSION CHARACTERISTICS .................................................................................. 628SHOW ........................................................................................................................... 628SHOW PROCEDURE ...................................................................................................... 629START TRANSACTION ................................................................................................... 630TRUNCATE .................................................................................................................... 630UNLOAD ........................................................................................................................ 631UPDATE ........................................................................................................................ 646VACUUM ....................................................................................................................... 650
SQL ............................................................................................................. 654 ................................................................................................... 655 .................................................................................. 656 ........................................................................................................................ 656 ...................................................................................................... 672 ............................................................................................................... 676 ........................................................................................................................... 721 ......................................................................................................... 729
x
-
Amazon Redshift
........................................................................................................................ 766 ..................................................................................................................... 790JSON ..................................................................................................................... 827 ................................................................................................ 833 ............................................................................................................ 842 ............................................................................................................ 849
................................................................................................................................... 863 ...................................................................................................... 866
........................................................................................................ 866 ........................................................................................... 866 ............................................................................... 867
................................................................................... 867 STL ................................................................................................ 868
STL_AGGR .................................................................................................................... 869STL_ALERT_EVENT_LOG ................................................................................................ 871STL_ANALYZE ............................................................................................................... 873STL_ANALYZE_COMPRESSION ....................................................................................... 874STL_BCAST ................................................................................................................... 875STL_COMMIT_STATS ..................................................................................................... 876STL_CONNECTION_LOG ................................................................................................. 878STL_DDLTEXT ............................................................................................................... 879STL_DELETE ................................................................................................................. 882STL_DISK_FULL_DIAG .................................................................................................... 884STL_DIST ...................................................................................................................... 885STL_ERROR .................................................................................................................. 886STL_EXPLAIN ................................................................................................................ 887STL_FILE_SCAN ............................................................................................................. 889STL_HASH ..................................................................................................................... 890STL_HASHJOIN .............................................................................................................. 892STL_INSERT .................................................................................................................. 893STL_LIMIT ..................................................................................................................... 894STL_LOAD_COMMITS ..................................................................................................... 896STL_LOAD_ERRORS ...................................................................................................... 898STL_LOADERROR_DETAIL .............................................................................................. 900STL_MERGE .................................................................................................................. 901STL_MERGEJOIN ........................................................................................................... 902STL_NESTLOOP ............................................................................................................. 904STL_PARSE ................................................................................................................... 905STL_PLAN_INFO ............................................................................................................ 906STL_PROJECT ............................................................................................................... 908STL_QUERY .................................................................................................................. 909STL_QUERY_METRICS ................................................................................................... 911STL_QUERYTEXT ........................................................................................................... 914STL_REPLACEMENTS .................................................................................................... 916STL_RESTARTED_SESSIONS ......................................................................................... 917STL_RETURN ................................................................................................................ 918STL_S3CLIENT ............................................................................................................... 919STL_S3CLIENT_ERROR .................................................................................................. 921STL_SAVE ..................................................................................................................... 922STL_SCAN ..................................................................................................................... 923STL_SESSIONS .............................................................................................................. 925STL_SORT ..................................................................................................................... 926STL_SSHCLIENT_ERROR ............................................................................................... 928STL_STREAM_SEGS ...................................................................................................... 928STL_TR_CONFLICT ........................................................................................................ 929STL_UNDONE ................................................................................................................ 930STL_UNIQUE ................................................................................................................. 931
xi
-
Amazon Redshift
STL_UNLOAD_LOG ........................................................................................................ 932STL_USERLOG .............................................................................................................. 933STL_UTILITYTEXT .......................................................................................................... 934STL_VACUUM ................................................................................................................ 937STL_WINDOW ................................................................................................................ 939STL_WLM_ERROR ......................................................................................................... 940STL_WLM_RULE_ACTION ............................................................................................... 941STL_WLM_QUERY .......................................................................................................... 941
STV ................................................................................... 943STV_ACTIVE_CURSORS ................................................................................................. 944STV_BLOCKLIST ............................................................................................................ 944STV_CURSOR_CONFIGURATION .................................................................................... 947STV_EXEC_STATE ......................................................................................................... 948STV_INFLIGHT ............................................................................................................... 949STV_LOAD_STATE ......................................................................................................... 950STV_LOCKS ................................................................................................................... 952STV_PARTITIONS ........................................................................................................... 952STV_QUERY_METRICS ................................................................................................... 954STV_RECENTS .............................................................................................................. 958STV_SESSIONS ............................................................................................................. 959STV_SLICES .................................................................................................................. 960STV_STARTUP_RECOVERY_STATE ................................................................................ 960STV_TBL_PERM ............................................................................................................. 961STV_TBL_TRANS ........................................................................................................... 963STV_WLM_QMR_CONFIG ................................................................................................ 964STV_WLM_CLASSIFICATION_CONFIG .............................................................................. 965STV_WLM_QUERY_QUEUE_STATE ................................................................................. 966STV_WLM_QUERY_STATE .............................................................................................. 967STV_WLM_QUERY_TASK_STATE .................................................................................... 969STV_WLM_SERVICE_CLASS_CONFIG .............................................................................. 969STV_WLM_SERVICE_CLASS_STATE ................................................................................ 971
....................................................................................................................... 972SVCS_ALERT_EVENT_LOG ............................................................................................. 973SVV_COLUMNS ............................................................................................................. 975SVCS_COMPILE ............................................................................................................. 976SVL_COMPILE ............................................................................................................... 978SVCS_CONCURRENCY_SCALING_USAGE ....................................................................... 979SVV_DISKUSAGE ........................................................................................................... 979SVCS_EXPLAIN .............................................................................................................. 981SVV_EXTERNAL_COLUMNS ............................................................................................ 983SVV_EXTERNAL_DATABASES ......................................................................................... 984SVV_EXTERNAL_PARTITIONS ......................................................................................... 984SVV_EXTERNAL_SCHEMAS ............................................................................................ 985SVV_EXTERNAL_TABLES ............................................................................................... 986SVV_INTERLEAVED_COLUMNS ....................................................................................... 986SVCS_PLAN_INFO .......................................................................................................... 987SVL_QERROR ................................................................................................................ 989SVL_QLOG .................................................................................................................... 989SVV_QUERY_INFLIGHT .................................................................................................. 991SVL_QUERY_METRICS ................................................................................................... 992SVL_QUERY_METRICS_SUMMARY .................................................................................. 993SVL_QUERY_QUEUE_INFO ............................................................................................. 994SVL_QUERY_REPORT .................................................................................................... 995SVV_QUERY_STATE ...................................................................................................... 997SVCS_QUERY_SUMMARY .............................................................................................. 999SVL_QUERY_SUMMARY ............................................................................................... 1001SVCS_S3LIST ............................................................................................................... 1004
xii
-
Amazon Redshift
SVL_S3LIST ................................................................................................................. 1004SVCS_S3LOG ............................................................................................................... 1005SVL_S3LOG ................................................................................................................. 1006SVL_S3PARTITION ....................................................................................................... 1007SVCS_S3PARTITION_SUMMARY .................................................................................... 1008SVL_S3PARTITION_SUMMARY ...................................................................................... 1009SVL_S3QUERY ............................................................................................................. 1010SVCS_S3QUERY_SUMMARY ......................................................................................... 1012SVL_S3QUERY_SUMMARY ............................................................................................ 1014SVL_S3RETRIES .......................................................................................................... 1016SVL_STATEMENTTEXT ................................................................................................. 1017SVL_STORED_PROC_CALL ........................................................................................... 1019SVCS_STREAM_SEGS .................................................................................................. 1021SVV_TABLES ............................................................................................................... 1021SVV_TABLE_INFO ........................................................................................................ 1022SVV_TRANSACTIONS ................................................................................................... 1024SVL_UDF_LOG ............................................................................................................. 1026SVCS_UNLOAD_LOG .................................................................................................... 1028SVL_USER_INFO .......................................................................................................... 1029SVV_VACUUM_PROGRESS ........................................................................................... 1029SVV_VACUUM_SUMMARY ............................................................................................. 1031SVL_VACUUM_PERCENTAGE ....................................................................................... 1032
...................................................................................................... 1032PG_CLASS_INFO .......................................................................................................... 1033PG_DATABASE_INFO .................................................................................................... 1034PG_DEFAULT_ACL ....................................................................................................... 1035PG_EXTERNAL_SCHEMA .............................................................................................. 1036PG_LIBRARY ................................................................................................................ 1037PG_PROC_INFO ........................................................................................................... 1038PG_STATISTIC_INDICATOR ........................................................................................... 1038PG_TABLE_DEF ........................................................................................................... 1039 .................................................................................. 1041
.......................................................................................................................... 1046 ............................................................................................................... 1046analyze_threshold_percent ...................................................................................................... 1047
() .................................................................................................... 1047 ............................................................................................................................. 1047 ................................................................................................................................ 1047
auto_analyze ......................................................................................................................... 1047 () .................................................................................................... 1047 ............................................................................................................................. 1047 ................................................................................................................................ 1048
datestyle .............................................................................................................................. 1048 () .................................................................................................... 1048 ............................................................................................................................. 1048 ................................................................................................................................ 1048
describe_field_name_in_uppercase ........................................................................................... 1048 () .................................................................................................... 1048 ............................................................................................................................. 1048 ................................................................................................................................ 1048
enable_result_cache_for_session .............................................................................................. 1049 () .................................................................................................... 1049 ............................................................................................................................. 1048
extra_float_digits .................................................................................................................... 1049 () .................................................................................................... 1049 ............................................................................................................................. 1049
max_concurrency_scaling_clusters ........................................................................................... 1049
xiii
-
Amazon Redshift
() .................................................................................................... 1049 ............................................................................................................................. 1049
max_cursor_result_set_size ..................................................................................................... 1049 () .................................................................................................... 1049 ............................................................................................................................. 1050
query_group .......................................................................................................................... 1050 () .................................................................................................... 1050 ............................................................................................................................. 1050
search_path .......................................................................................................................... 1050 () .................................................................................................... 1050 ............................................................................................................................. 1051 ................................................................................................................................ 1051
statement_timeout .................................................................................................................. 1052 () .................................................................................................... 1052 ............................................................................................................................. 1052 ................................................................................................................................ 1052
timezone .............................................................................................................................. 1052 () .................................................................................................... 1052 ............................................................................................................................. 1052 ............................................................................................................................. 1053 .......................................................................................................... 1053 ................................................................................................................................ 1054
wlm_query_slot_count ............................................................................................................. 1055 () .................................................................................................... 1055 ............................................................................................................................. 1055 ................................................................................................................................ 1055
.................................................................................................................... 1057CATEGORY ............................................................................................................ 1058DATE ..................................................................................................................... 1058EVENT ................................................................................................................... 1059VENUE ................................................................................................................... 1059USERS ................................................................................................................... 1059LISTING ................................................................................................................. 1060SALES ................................................................................................................... 1060
: ................................................................................................... 1062 ............................................................................................................... 1062 ............................................................................................................ 1071
.......................................................................................................................... 1075 ........................................................................................................................... 1078
xiv
-
Amazon Redshift Amazon Redshift
Amazon Redshift (p. 1) (p. 2) (p. 3)
Amazon Redshift Database Developer Guide
Amazon Redshift
Amazon Redshift
Amazon Redshift
Amazon Redshift
Amazon Redshift
Amazon Redshift Amazon Redshift
1
Amazon Redshift Cluster Management Guide Amazon Redshift
Amazon Redshift Query API Amazon Redshift API AWS SDK Amazon Redshift AWS (AWS CLI) API CLI API CLI
Amazon Redshift Database Developer Guide ()
Amazon RedshiftAmazon Redshift Amazon Redshift
1
https://aws.amazon.com/redshift/https://docs.aws.amazon.com/redshift/latest/gsg/https://docs.aws.amazon.com/redshift/latest/mgmt/https://docs.aws.amazon.com/redshift/latest/APIReference/https://docs.aws.amazon.com/cli/latest/reference/redshift/ -
Amazon Redshift
(p. 26)Amazon Redshift (p. 29)Amazon Redshift PostgreSQL 8.0.2 Amazon Redshift PostgreSQL Amazon Redshift PostgreSQL (p. 354)
Amazon Redshift
Amazon Redshift
Amazon Redshift
Amazon Redshift (p. 4)Amazon Redshift
Amazon Redshift AmazonRedshift
(p. 13) SQL
Amazon Redshift SQL (p. 353)Amazon Redshift SQL SQL
Amazon Redshift (p. 26)
(p. 122)
(p. 192) AmazonDynamoDB Amazon S3
Amazon Redshift (p. 29)
(p. 115)
(p. 866)
2
https://docs.aws.amazon.com/redshift/latest/gsg/https://aws.amazon.com/redshift/https://aws.amazon.com/redshift/ -
Amazon Redshift
Amazon Redshift Cluster Management Guide AWS
Amazon Redshift Amazon Redshift
SQL (p. 353)Amazon Redshift SQL
SQL Amazon Redshift SQL
Amazon Redshift
SQL SQL
3
https://docs.aws.amazon.com/redshift/latest/mgmt/https://aws.amazon.com/redshift/partners/https://docs.aws.amazon.com/redshift/latest/gsg/ -
Amazon Redshift
Amazon Redshift
(p. 4) (p. 6) (p. 8) (p. 10) (p. 11) Amazon Redshift (p. 11)
Amazon Redshift
Amazon Redshift (BI)
Amazon Redshift Amazon Redshift
Amazon Redshift
4
-
Amazon Redshift
Amazon Redshift ETL () (BI) Amazon Redshift PostgreSQL SQL Amazon Redshift SQL PostgreSQL AmazonRedshift PostgreSQL (p. 354)
Amazon Redshift PostgreSQL JDBC ODBC Amazon Redshift PostgreSQL JDBC/ODBC (p. 355)
Amazon Redshift
1 2
SQL Amazon Redshift SQL SQL (p. 353)
CPU
Amazon Redshift 2 2 160 GB 1 16 TB
(p. 10)
5
-
Amazon Redshift
Amazon Redshift Cluster Management Guide
1 Amazon Redshift (p. 27)
Amazon Redshift
1 SQL
Amazon Redshift (RDBMS) RDBMS Amazon Redshift RDBMS ( (OLTP) )
Amazon Redshift PostgreSQL 8.0.2 Amazon Redshift PostgreSQL Amazon Redshift SQL PostgreSQL Amazon Redshift PostgreSQL (p. 354)
Amazon Redshift
(p. 6) (p. 7) (p. 7) (p. 7) (p. 7) (p. 8)
(MPP)
6
https://docs.aws.amazon.com/redshift/latest/mgmt/working-with-clusters.html#rs-about-clusters-and-nodeshttps://docs.aws.amazon.com/redshift/latest/mgmt/working-with-clusters.html#rs-about-clusters-and-nodes -
Amazon Redshift
Amazon Redshift (p. 27)
Amazon Redshift (p. 29)
I/O I/O Amazon Redshift (p. 8)
(p. 27)
I/O Amazon Redshift Amazon Redshift Amazon Redshift (p. 218)
Amazon Redshift MPP Amazon Redshift (p. 294)
Amazon Redshift Amazon Redshift Amazon Redshift
enable_result_cache_for_session (p. 1049) off
Amazon Redshift
7
-
Amazon Redshift
GETDATE Amazon Redshift Spectrum
Amazon Redshift Amazon Redshift AmazonRedshift
SVL_QLOG (p. 989) source_query IDsource_query Null
ID 104 ID 102 ID 100
select userid, query, elapsed, source_query from svl_qlog where userid > 1order by query desc;
userid | query | elapsed | source_query-------+--------+----------+------------- 104 | 629035 | 27 | 628919 104 | 629034 | 60 | 628900 104 | 629033 | 23 | 628891 102 | 629017 | 1229393 | 102 | 628942 | 28 | 628919 102 | 628941 | 57 | 628900 102 | 628940 | 26 | 628891 100 | 628919 | 84295686 | 100 | 628900 | 87015637 | 100 | 628891 | 58808694 |
(p. 47) 2: (p. 51)
() 2
JDBC ODBC psql (libq) 2
I/O
8
-
Amazon Redshift
1 1 1 1 (OLTP) 1 OLTP
1 Amazon Redshift
3 I/O 3 1
I/O (p. 123)
1 OLTP
9
-
Amazon Redshift
I/O 1 100 5 5 95
232 KB Amazon Redshift 1MB I/O
Amazon Redshift
10
-
Amazon Redshift
Amazon Redshift (WLM)
Amazon Redshift WLM
WLM
WLM WLM WLM (p. 324)
WLM Amazon Redshift 5 ( 5 ) 1 1 8 50 () 50
WLM Amazon Redshift Amazon Redshift CLI Amazon Redshift API
(p. 322)
Amazon Redshift Amazon Redshift AWS
Amazon Redshift Amazon S3 Amazon Simple Storage Service (Amazon S3) Amazon Redshift Amazon S3 Amazon S3 (p. 195)
Amazon Redshift Amazon S3 (p. 251)
Amazon Redshift Amazon DynamoDB Amazon DynamoDB NoSQL COPY 1 Amazon DynamoDB Amazon Redshift
11
-
Amazon Redshift SSH
Amazon DynamoDB (p. 214)
SSH Amazon Redshift COPY Amazon EMR Amazon EC2 1 COPY SSH Amazon Redshift COPY (p. 208)
AWS Data Pipeline AWS Data Pipeline Amazon Redshift AWSData Pipeline Amazon DynamoDB Amazon Redshift Amazon S3 Amazon Redshift AWS Data Pipeline Amazon RedshiftAWS Data Pipeline
AWS Database Migration Service (AWS DMS)AWS Database Migration Service Amazon Redshift AWS DMSOraclePostgreSQLMicrosoft SQL ServerAmazon RedshiftAuroraDynamoDBAmazonS3MariaDBMySQL AWS Database Migration Service Amazon Redshift
12
https://docs.aws.amazon.com/datapipeline/latest/DeveloperGuide/dp-copydata-redshift.htmlhttps://docs.aws.amazon.com/dms/latest/userguide/CHAP_Target.Redshift.htmlhttps://docs.aws.amazon.com/dms/latest/userguide/CHAP_Target.Redshift.html -
Amazon Redshift 1:
1: (p. 13) 2: (p. 14) 3: (p. 14) 4: (p. 16) 5: (p. 16) 6: (p. 18) 7: (p. 20)
Amazon Redshift
Amazon Redshift SQL Amazon Redshift
Important
AWS Amazon Redshift
1: 1 TICKIT ORDERS 1
()
tickit
create database tickit;
SQL CREATE DATABASE (p. 502)
TICKIT SQL tickit
13
https://docs.aws.amazon.com/redshift/latest/gsg/https://aws.amazon.com/redshift/pricing/ -
Amazon Redshift 2:
TICKIT
2:
CREATE USER 864 1
GUEST ABCd4321
create user guest password 'ABCd4321';
SQL CREATE USER (p. 549)
GUEST
GUEST
drop user guest;
Important
Amazon Redshift
SQL DROP USER (p. 567)
3:
testtable 1 testcol
create table testtable (testcol int);
14
-
Amazon Redshift
PG_TABLE_DEF SELECT PG_TABLE_DEF
select * from pg_table_def where tablename = 'testtable';
schemaname|tablename|column | type |encoding|distkey|sortkey | notnull----------+---------+-------+-------+--------+-------+--------+--------- public |testtable|testcol|integer|none |f | 0 | f(1 row)
public (p. 118)
encoding distkey sortkey Amazon Redshift Amazon Redshift (p. 26)
Note
INSERT (p. 582) COPY (p. 443) COPY (p. 30)
1 100 testtable
insert into testtable values (100);
SELECT SELECT *
testtable
select * from testtable;
testcol---------100(1 row)
SELECT SQL SELECT (p. 596)
15
-
Amazon Redshift 4:
4: TICKIT SQL TICKIT
AWS Amazon S3 Amazon S3 AWS
TICKIT COPY Amazon S3 Amazon Redshift
5:
Note
System Tables Reference
Amazon Redshift
STL (p. 868)
Amazon Redshift STL
STV (p. 943)
STV
(p. 972)
STL STV SVV SVL
(p. 1032)
PG
ID ID (p. 18)
PG_TABLE_DEF
16
https://docs.aws.amazon.com/redshift/latest/gsg/getting-started.html -
Amazon Redshift
select distinct(tablename) from pg_table_def where schemaname = 'public';
tablename---------categorydateeventlistingsalestesttableusersvenue
IDUSESYSIDPG_USER
select * from pg_user; usename | usesysid | usecreatedb | usesuper | usecatupd | passwd | valuntil | useconfig
------------+----------+-------------+----------+-----------+----------+----------+----------- rdsdb | 1 | t | t | t | ******** | | masteruser | 100 | t | t | f | ******** | | dwuser | 101 | f | f | f | ******** | | simpleuser | 102 | f | f | f | ******** | | poweruser | 103 | f | t | f | ******** | | dbuser | 104 | t | f | f | ******** | |(6 rows)
Amazon Redshift rdsdbSELECT where usesysid > 1
select * from pg_userwhere usesysid > 1;
usename | usesysid | usecreatedb | usesuper | usecatupd | passwd | valuntil | useconfig------------+----------+-------------+----------+-----------+----------+----------+----------- masteruser | 100 | t | t | f | ******** | | dwuser | 101 | f | f | f | ******** | | simpleuser | 102 | f | f | f | ******** | | poweruser | 103 | f | t | f | ******** | | dbuser | 104 | t | f | f | ******** | |(5 rows)
ID (USESYSID) 100 5 SVL_QLOG SVL_QLOG STL_QUERY ID (QUERY) ID (PID)
17
-
Amazon Redshift ID
SVL_QLOG (SUBSTRING) 60 SELECT LIMIT 5
select query, pid, elapsed, substring from svl_qlogwhere userid = 100order by starttime desclimit 5;
query | pid | elapsed | substring--------+-------+----------+-------------------------------------------------------------- 187752 | 18921 | 18465685 | select query, elapsed, substring from svl_qlog order by query 204168 | 5117 | 59603 | insert into testtable values (100); 187561 | 17046 | 1003052 | select * from pg_table_def where tablename = 'testtable'; 187549 | 17046 | 1108584 | select * from STV_WLM_SERVICE_CLASS_CONFIG 187468 | 17046 | 5670661 | select * from pg_table_def where schemaname = 'public';(5 rows)
ID ID ID (PID) SVL_QLOG
PID PID STV_RECENTS ID PID PID
PID STATEMENT
select pid, user_name, starttime, queryfrom stv_recentswhere status='Running';
6: SALES USERS WHERE SELLERID USERID 2
select sellerid, firstname, lastname, sum(qtysold)from sales, userswhere sales.sellerid = users.useridgroup by sellerid, firstname, lastnameorder by 4 desc;
Note
18
-
Amazon Redshift
2,102
WHERE
select sellerid, firstname, lastname, sum(qtysold)from sales, usersgroup by sellerid, firstname, lastnameorder by 4 desc;
SALES USERS (499893766) 1 8800
CANCEL PID
ID STV_RECENTS TRIM 20
select pid, trim(user_name), starttime, substring(query,1,20) from stv_recentswhere status='Running';
pid | btrim | starttime | substring-------+------------+----------------------------+---------------------- 18764 | masteruser | 2013-03-28 18:39:49.355918 | select sellerid, fir(1 row)
PID 18764
cancel 18764;
Note
CANCEL ABORT ROLLBACK
ABORT ROLLBACK
abort;
Amazon Redshift SQLWorkbench SQL Workbench [File][New Window] PID
19
-
Amazon Redshift Superuser
Superuser CANCEL CANCEL
Superuser Superuser SET superuserRESET
Superuser
set query_group to 'superuser';cancel 18764;reset query_group;
(p. 322)
7: AWS
Amazon Redshift Cluster Management Guide
TICKIT
drop database tickit;
TICKIT
drop table testtable;drop table users;drop table venue;drop table category;drop table date;drop table event;drop table listing;drop table sales;
20
https://docs.aws.amazon.com/redshift/latest/mgmt/managing-clusters-console.html#delete-cluster -
Amazon Redshift PoC ()
Amazon Redshift PoC ()
Amazon Redshift SQL AmazonRedshift 10
Amazon Redshift PoC () Amazon Redshift
Amazon Redshift Amazon Redshift Amazon Redshift Amazon Redshift
PoC () PoC () PoC ()
(SLA) Amazon Redshift SQL
(: ) SQL
(ETL)
PoC () SMART
PoC () Amazon Redshift PoC () 2 AWS 2
2
21
https://docs.aws.amazon.com/redshift/latest/gsg/getting-started.htmlhttps://aws.amazon.com/redshift/https://aws.amazon.com/pricing/https://en.wikipedia.org/wiki/SMART_criteria -
Amazon Redshift
Dense Storage: (HDD)
Dense Compute: CPURAM SSD (Solid-State Disk)
AWS
2 ()
Virtual Private Cloud (VPC) EC2-Classic
20 3
AWS Schema Conversion Tool (AWS SCT) AWS Database Migration Service (AWS DMS)
Amazon Redshift
Oracle Amazon Redshift AWS CloudFormation AWS DMSAWS SCT
AWS SCT Amazon Redshift AWS SCT Amazon Redshift
5 SET DW
S S 3
AWS
E E Amazon Redshift Amazon Redshift
22
http