CREATE VIEW

You can execute the CREATE VIEW statement to create a view in PolarDB-X.

Syntax

CREATE
[OR REPLACE]
VIEW view_name [(column_list)]
AS select_statement

Examples

# Create a table.
CREATE TABLE t_order (
  `id` bigint(11) NOT NULL AUTO_INCREMENT,
  `order_id` varchar(20) DEFAULT NULL,
  `buyer_id` varchar(20) DEFAULT NULL,
  `seller_id` varchar(20) DEFAULT NULL,
  `order_snapshot` longtext DEFAULT NULL,
  `order_detail` longtext DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `l_i_order` (`order_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 dbpartition by hash(`order_id`);

# Create a view.
create view t_detail as select order_id,order_detail from t_order;

# Query the view.
select * from t_detail;

results matching ""

    No results matching ""