《mac上postgresql入门》要点:
本文介绍了mac上postgresql入门,希望对您有用。如果有疑问,可以联系我们。
brew install postgresql
启动postgres -D /usr/local/var/postgres
新建用户 -s表现超管/usr/local/Cellar/postgresql/9.5.3/bin/createuser -s root
创立数据库/usr/local/Cellar/postgresql/9.5.3/bin/createdb root
客户端登录psql -U root
创立表CREATE table COMPANY(
ID INT PRIMARY KEY NOT NulL,
name TEXT NOT NulL,
AGE INT NOT NulL,
ADDRESS CHAR(50),
SALARY REAL,
JOIN_DATE DATE
);
CREATE table DEPARTMENT(
ID INT PRIMARY KEY NOT NulL,
DEPT CHAR(50) NOT NulL,
EMP_ID INT NOT NulL
);
查看所有表\d
查看某表布局\d company
删除了表drop table company;
创建模式 其实便是表的分组create schema myschema;
在模式中创立表create table myschema.company(
ID INT NOT NulL,
name VARCHAR (20) NOT NulL,
ADDRESS CHAR (25),
SALARY DECIMAL (18,2),
PRIMARY KEY (ID)
);
删除了模式DROP SCHEMA my schema;
强制删除了模板DROP SCHEMA myschema CASCADE;
新增记载INSERT INTO COMPANY (ID,name,AGE,ADDRESS,SALARY,JOIN_DATE) VALUES (1,'Paul',32,'California',20000.00,'2001-07-13');
INSERT INTO COMPANY (ID,JOIN_DATE) VALUES (2,'Allen',25,'Texas','2007-12-13');
INSERT INTO COMPANY (ID,JOIN_DATE) VALUES (3,'Teddy',23,'norway',DEFAulT );
INSERT INTO COMPANY (ID,JOIN_DATE) VALUES (4,'Mark','Rich-Mond',65000.00,'2007-12-13'),(5,'DavID',27,85000.00,'2007-12-13');
查询select * from company;
select ID,name,age from company;
SELECT * FROM COMPANY WHERE SALARY = 20000;
SELECT COUNT(*) AS "RECORDS" FROM COMPANY;
SELECT * FROM COMPANY liMIT 2 offset 1;
SELECT * FROM COMPANY liMIT 2;
SELECT * FROM COMPANY WHERE address::text like 'T%';
注意非string字段SELECT * FROM COMPANY WHERE AGE::text liKE '2%';
下划线表现一个字符SELECT * FROM COMPANY WHERE AGE::text liKE '2_';
改动UPDATE COMPANY SET SALARY =15000 WHERE ID =6;
删除了DELETE FROM COMPANY WHERE ID =2;
《mac上postgresql入门》是否对您有启发,欢迎查看更多与《mac上postgresql入门》相关教程,学精学透。内存溢出PHP学院为您提供精彩教程。
总结以上是内存溢出为你收集整理的mac上postgresql入门全部内容,希望文章能够帮你解决mac上postgresql入门所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)