SQLite でテーブル定義

このページでは SQLite を使い、次のテーブルを定義する.データベース名は my.dbとしている.

前準備

前もって,SQLite をインストールしておくこと.

SQLite でテーブル定義

  1. SQLite を実行する.

    * パスが通っていないときは,パスを通すか,フルパスで実行する

    sqlite3
    
  2. 空のデータベースを新規作成
    .open --new my.db
    .exit
    
  3. テーブルを定義したいので,次の SQL プログラムを実行.

    * 「.exit」で終了する

    /* 3-dimensional Graphcs */
    create table Point3 (
      x real not null, 
      y real not null, 
      z real not null );
    create table Point3Color (
      x real not null, 
      y real not null, 
      z real not null,
      r integer, 
      g integer, 
      b integer, 
      a integer );
    create table Point3Normal (
      x real not null, 
      y real not null, 
      z real not null,
      nx real, 
      ny real, 
      nz real ); 
    create table Polygon3 (
      id integer primary key not null, 
      nx real, 
      ny real, 
      nz real ); 
    create table Point3Polygon3 (
      point3 integer not null,  
      polygon3 integer not null );