Table定義

MySQLにおけるテーブル定義の確認方法

How to check the table definition in case of MySQL.

root@localhost [gis]> desc temp1;
+-----------+------------+------+-----+---------+----------------+
| Field     | Type       | Null | Key | Default | Extra          |
+-----------+------------+------+-----+---------+----------------+
| town_id   | bigint(20) | NO   | PRI | NULL    | auto_increment |
| pref_code | varchar(2) | NO   |     | -       |                |
| pref_name | varchar(4) | NO   |     | -       |                |
+-----------+------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)


root@localhost [gis]> show create table temp1\G
*************************** 1. row ***************************
       Table: temp1
Create Table: CREATE TABLE `temp1` (
  `town_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '大字・町丁目レベルID',
  `pref_code` varchar(2) NOT NULL DEFAULT '-' COMMENT 'JIS都道府県コード',
  `pref_name` varchar(4) NOT NULL DEFAULT '-' COMMENT '都道府県名',
  PRIMARY KEY (`town_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC
1 row in set (0.00 sec)

root@localhost [gis]>

PostgreSQLにおけるテーブル定義の確認方法

How to check the table definition in case of PostgreSQL

scaffold_app_development=# \d users;
                                     Table "public.users"
   Column   |            Type             |                     Modifiers                      
------------+-----------------------------+----------------------------------------------------
 id         | bigint                      | not null default nextval('users_id_seq'::regclass)
 name       | character varying           | 
 age        | integer                     | 
 created_at | timestamp without time zone | not null
 updated_at | timestamp without time zone | not null
Indexes:
    "users_pkey" PRIMARY KEY, btree (id)

scaffold_app_development=# \d+ users;
                                                         Table "public.users"
   Column   |            Type             |                     Modifiers                      | Storage  | Stats target | Description 
------------+-----------------------------+----------------------------------------------------+----------+--------------+-------------
 id         | bigint                      | not null default nextval('users_id_seq'::regclass) | plain    |              | 
 name       | character varying           |                                                    | extended |              | 
 age        | integer                     |                                                    | plain    |              | 
 created_at | timestamp without time zone | not null                                           | plain    |              | 
 updated_at | timestamp without time zone | not null                                           | plain    |              | 
Indexes:
    "users_pkey" PRIMARY KEY, btree (id)
Has OIDs: no

scaffold_app_development=# 

PostgreSQLにおけるテーブル定義確認

Categories:

Tags:

Comments are closed