azexcy commented on PR #27983:
URL: https://github.com/apache/shardingsphere/pull/27983#issuecomment-1668865510

   The primary key will have a unique index
   
   MySQL 
   
   ```
   mysql> CREATE TABLE t_order (order_id INT NOT NULL, user_id INT NOT NULL, 
status VARCHAR(50), PRIMARY KEY (order_id))
   
   mysql> describe t_order;
   +----------+-------------+------+-----+---------+-------+
   | Field    | Type        | Null | Key | Default | Extra |
   +----------+-------------+------+-----+---------+-------+
   | order_id | int         | NO   | PRI | NULL    |       |
   | user_id  | int         | NO   |     | NULL    |       |
   | status   | varchar(50) | YES  |     | NULL    |       |
   +----------+-------------+------+-----+---------+-------+
   3 rows in set (0.01 sec)
   
   mysql> SHOW INDEX FROM t_order;
   
+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
   | Table   | Non_unique | Key_name | Seq_in_index | Column_name | Collation | 
Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | 
Visible | Expression |
   
+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
   | t_order |          0 | PRIMARY  |            1 | order_id    | A         | 
          0 |     NULL |   NULL |      | BTREE      |         |               | 
YES     | NULL       |
   
+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
   1 row in set (0.01 sec)
   ```
   
   
   PostgreSQL
   
   ```
   create table t_order (
     order_id integer primary key ,
     user_id integer not null,
     status character varying(255)
   );
   
   postgres=# \c ds_0
   You are now connected to database "ds_0" as user "aze".
   ds_0=# \d t_order
                          Table "public.t_order"
     Column  |          Type          | Collation | Nullable | Default
   ----------+------------------------+-----------+----------+---------
    order_id | integer                |           | not null |
    user_id  | integer                |           | not null |
    status   | character varying(255) |           |          |
   Indexes:
       "t_order_pkey" PRIMARY KEY, btree (order_id)
   
   ds_0=# SELECT * FROM pg_indexes WHERE tablename = 't_order';
    schemaname | tablename |  indexname   | tablespace |                        
         indexdef
   
------------+-----------+--------------+------------+---------------------------------------------------------------------------
    public     | t_order   | t_order_pkey |            | CREATE UNIQUE INDEX 
t_order_pkey ON public.t_order USING btree (order_id)
   (1 row)
   
   ds_0=#
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to