PostgreSQL
增:
alter table 表名 add 字段 数据类型; 增加新列
alter table 表名 add primary key(字段); 增加主键
insert into 表名 values (值,值,值); 插入一行数据
create index 索引名 on 表名; 增加索引
删:
drop table 表名; 删除表
alter table 表名 drop 字段; 删除字段/列
delete from 表名 where 字段 = 值(如:id = 5); 删除指定行
drop index 索引名; 删除指定索引
查:
select * from information_schema.columns where table_name = '表名'; 查看表结构
select * from pg_indexes where tablename = '表名'; 查看表中的索引(tablename中间没有下划线)
select * from 表名; 查看表内信息(四库通用)
改:
alter table 表名 rename to 新表名; 改表名
alter table 表名 rename 旧字段名 to 新字段名; 改字段名
alter table 表名 alter 被修改的字段名 type 数据类型; 改字段的数据类型
update 表名 set 字段 = ‘值’ where 字段 = ‘值’(如:id = 3); 改指定的数据项的值
下篇主题为SQL server
点此跳转到ORACLE常用SQL 点此跳转到mysql的常用SQL 点此跳转到SqlServer数据库常用SQL操作