After a DRDS database is created, you must create tables. This topic describes how to create a DRDS table.

  1. Log on to the DRDS console.
  2. In the top navigation bar, select the region where the target instance is located.
  3. Find the target instance and click the instance ID to go to the Basic Information page.
  4. In the left-side navigation pane, click Database Management.
  5. On the Databases page, find the target database and click the database ID to go to the Basic Information page.
  6. In the VPC Address area, find the Command Line Link Address, which contains the DRDS connection string.
  7. After you obtain the DRDS connection string, you can use the following MySQL command to establish a connection to the DRDS database:
    mysql -h${DRDS_ENDPOINT} -P${DRDS_PORT} -u${user} -p${password} -D${DRDS_DBNAME}
    Note The DRDS instance is a dedicated instance, and only the internal endpoint is provided by default. Therefore, we recommend that you install the MySQL command line on an Elastic Compute Service (ECS) instance that is in the same region as the DRDS instance.
  8. Execute the following statement to create a table:
    //DRDS DDL
    CREATE TABLE shard_table(
      id int,
      name varchar(30),
      primary key(id)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 dbpartition by hash(id) tbpartition by hash(id) tbpartitions 3;