Create tables using Amazon Glue or the Athena console - Amazon Athena
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Create tables using Amazon Glue or the Athena console

You can create tables in Athena by using Amazon Glue, the add table form, or by running a DDL statement in the Athena query editor.

To create a table using the Amazon Glue crawler

  1. Open the Athena console at https://console.amazonaws.cn/athena/.

  2. In the query editor, next to Tables and views, choose Create, and then choose Amazon Glue crawler.

  3. Follow the steps on the Add crawler page of the Amazon Glue console to add a crawler.

    For more information, see Use a crawler to add a table.

To create a table using the Athena create table form

  1. Open the Athena console at https://console.amazonaws.cn/athena/.

  2. In the query editor, next to Tables and views, choose Create, and then choose S3 bucket data.

  3. In the Create Table From S3 bucket data form, enter the information to create your table, and then choose Create table. For more information about the fields in the form, see Use a form in the Athena console to add an Amazon Glue table.

To create a table using a CREATE TABLE statement in the Athena query editor

  1. From the Database menu, choose the database for which you want to create a table. If you don't specify a database in your CREATE TABLE statement, the table is created in the database that is currently selected in the query editor.

  2. Enter a statement like the following in the query editor, and then choose Run, or press Ctrl+ENTER.

    CREATE EXTERNAL TABLE IF NOT EXISTS cloudfront_logs ( `Date` Date, Time STRING, Location STRING, Bytes INT, RequestIP STRING, Method STRING, Host STRING, Uri STRING, Status INT, Referrer STRING, OS String, Browser String, BrowserVersion String ) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe' WITH SERDEPROPERTIES ( "input.regex" = "^(?!#)([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+[^\(]+[\(]([^\;]+).*\%20([^\/]+)[\/](.*)$" ) LOCATION 's3://athena-examples-MyRegion/cloudfront/plaintext/';