Postgres SQL学习笔记

1、创建表,添加,查询

create table StuInfo
(
   StuId  SERIAL primary key,-- 自动增长列
   StuName varchar(20),
   Birthday Date,
   StuPhone  varchar(11)
)

insert into StuInfo(StuName,Birthday,StuPhone) values('张三',NOW(),'12345678911') -- 添加   SQLite获取系统时间datetime('now') 

select * from StuInfo -- 查询

 2、查询表的所有字段

select a.attname from pg_class as c,pg_attribute as a where c.relname='tablename' and a.attrelid=c.oid and a.attnum>0

 3、修改字段名

ALTER TABLE public.ss_db_table RENAME "DT_Name" TO dt_name;

 

posted on 2016-11-10 17:32  Geography爱好者  阅读(673)  评论(0编辑  收藏  举报

导航