Red > Green > Refactor > Red

cycle is based on desire

Read View 作成

CREATE TABLE trial_table (
  trial_id INTEGER
    NOT NULL,
  name CHAR(20)
    NOT NULL,
  age INTEGER
    NOT NULL
    CONSTRAINT trial_age_range
      CHECK(age BETWEEN 0 AND 200),
  PRIMARY KEY(trial_id)
);

INSERT INTO trial_table
  ( trial_id, name, age )
  VALUES
  ( 1, 'testX', 20 );

INSERT INTO trial_table
  ( trial_id, name, age )
  VALUES
  ( 2, 'testY', 30 );

SELECT * FROM trial_table;

 trial_id |         name         | age 
----------+----------------------+-----
        1 | testX                |  20
        2 | testY                |  30
CREATE VIEW trial_view
(trialid, trialname, userage, appendixdata)
AS
SELECT trial_id, name, age, +50 
FROM trial_table;

SELECT * FROM trial_view;

 trialid |      trialname       | userage | appendixdata 
---------+----------------------+---------+--------------
       1 | testX                |      20 |           50
       2 | testY                |      30 |           50