《mac上postgresql入门》要点:
本文介绍了mac上postgresql入门,希望对您有用。如果有疑问,可以联系我们。
相关主题:PostgreSQL教程
brew install postgresql
postgres -D /usr/local/var/postgres
/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,
AGE INT 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,NAME,AGE,ADDRESS,JOIN_DATE) VALUES (2,'Allen',25, 'Texas','2007-12-13');
INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY,JOIN_DATE) VALUES (3,'Teddy',23,'Norway',20000.00, DEFAULT );
INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY,JOIN_DATE) VALUES (4,'Mark',25, 'Rich-Mond',65000.00,'2007-12-13'),(5,'David',27,'Texas',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%';
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学院为您提供精彩教程。