使用 AWS Glue 或 Athena 主控台建立資料表 - Amazon Athena

使用 AWS Glue 或 Athena 主控台建立資料表

您可以透過使用 AWS Glue、新增資料表表單或在 Athena 查詢編輯器中執行 DDL 陳述式等方式,在 Athena 中建立資料表。

若要使用 AWS Glue 爬蟲程式建立資料表

  1. 前往 https://console.aws.amazon.com/athena/ 開啟 Athena 主控台。

  2. 在查詢編輯器中,選擇位於資料表和檢視旁的建立,然後選擇 AWS Glue 爬蟲程式

  3. 請依照 AWS Glue 主控台 Add crawler (新增爬蟲程式) 頁面上的步驟新增爬蟲程式。

    如需更多詳細資訊,請參閱 使用編目程式新增資料表

使用 Athena 新增資料表表單來建立資料表

  1. 前往 https://console.aws.amazon.com/athena/ 開啟 Athena 主控台。

  2. 在查詢編輯器中,選擇位在 Tables and views (資料表和檢視) 旁的 Create (建立),然後選擇 S3 bucket data (S3 儲存貯體資料)。

  3. Create Table From S3 bucket data (從 S3 儲存貯體資料建立資料表) 表單中,輸入用於建立資料表的資訊,然後選擇 Create table (建立資料表)。如需表單欄位的詳細資訊,請參閱在 Athena 主控台中使用表單來新增 AWS Glue 資料表

在 Athena 查詢編輯器中,使用 CREATE TABLE 陳述式建立資料表

  1. Database (資料庫) 選單中,選擇要為其建立資料表的資料庫。如果您未在 CREATE TABLE 陳述式中指定資料庫,則會在查詢編輯器中目前選取的資料庫中建立資料表。

  2. 在查詢編輯器中,輸入下列範例所示的陳述式,然後選擇執行

    CREATE EXTERNAL TABLE myopencsvtable ( firstname string, lastname string, job string, country string ) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde' WITH SERDEPROPERTIES ( 'separatorChar' = ',', 'quoteChar' = '"', 'escapeChar' = '\\' ) STORED AS TEXTFILE LOCATION 's3://amzn-s3-demo-bucket/mycsv/';