1. 테이블 생성


CREATE TABLE weather ( city  varchar(80), temp_lo  int, temp_hi  int, prcp  real, date  date );

CREATE TABLE cities ( name  varchar(80), location  point );



2. 데이터 삽입


INSERT INTO weather VALUES('Seoul', 17, 29, 0.75, '2017-06-15');

INSERT INTO cities VALUES('Seoul', '(37.0, 126.0)');

INSERT INTO weather VALUES('Busan', 22, 31, 0.85, '2017-06-15');

INSERT INTO cities VALUES('Busan', '(35.0, 128.0)');


3. 데이터 조회


SELECT * FROM weather;

SELECT * FROM cities;



4. 데이터 수정


UPDATE weather SET temp_hi = temp_hi +2, temp_lo = temp_lo -2 WHERE date > '2000-01-01';



5. 데이터 삭제


DELETE FROM weather WHERE city ='Busan';

DELETE FROM cities WHERE name = 'Busan';



6.  테이블 삭제


DROP TABLE weather, cities CASCADE;

반응형

+ Recent posts