All Products
Document Center

Create a DRDS table

Last Updated: Apr 05, 2018

After a DRDS database is created, you need to create tables. The database creation syntax is different from that of a single-host database.


  1. Log on to the DRDS console.

  2. Click Instances in the left-side navigation pane.

  3. On the “Instances” page, click the name of the instance you want to operate.

  4. Click Databases in the left-side navigation pane.

  5. Click the name of the database for which you want to create a table.

  6. On the Basic Information page, copy Command Line URL, which is the DRDS database connection string.

  7. Connect to the DRDS database through a MySQL client.

    For example, you can establish a connection using the MySQL command line as follows:

    1. mysql -h${DRDS_IP_ADDRESS} -P${DRDS_PORT} -u${user} -p${password} -D${DRDS_DBNAME}


    • If the DRDS instance is an exclusive instance, only the intranet address is provided by default. We recommend that you install the MySQL command line on an ECS instance that is in the same region as the DRDS instance.

    • If the DRDS instance is a shared instance, you can connect to the DRDS database by using its Internet address from an Internet-based or office computer.

  8. Run the DRDS DDL statement to create a table.

    1. //DRDS DDL
    2. CREATE TABLE shard_table(
    3. id int,
    4. name varchar(30),
    5. primary key(id)
    6. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 dbpartition by hash(id) tbpartition by hash(id) tbpartitions 3;