自己安装的openGauss环境
启动openGauss
gs_ctl -D /gauss/data/db1/ start
登录openGauss
gsql -d postgres -p 26000 -r
1.创建一个表products_hc
字段名 数据类型 含义
product_id INTEGER 产品编号
product_name Char(30) 产品名
category Char(20) 种类
create table products_hc
(product_id INTEGER,
product_name Char(30),
category Char(20)
);

2.向表中插入数据,采用一次插入一条和多条记录的方式
product_id product_name category
1502 olympus camera electrncs
1601 lamaze toys
1700 wait interface Books
1666 harry potter toys
插入单条记录
insert into products_hc(product_id,product_name,category) values(1502,‘olympus camera’,‘electrncs’);

一次插入多条记录------批量插入,性能好
insert into products_hc(product_id,product_name,category) values(1601,‘lamaze’,‘toys’),(1700,‘wait interface’,‘Books’),(1666,‘harry potter’,‘toys’);

3.查询表中所有记录及记录数
select * from products_hc;
select count(*) from products_hc;

4.查询表中所有category记录,并将查询结果按升序排序
ASC为升序,DESC为降序,默认是ASC升序
select category from products_hc order by category;

5.查询表中category为toys的记录
select * from products_hc where category=‘toys’;------查询字段,最好有索引

6.删除表products_hc
drop table products_hc;





