|
| 1 | +# WSQL Toturial |
| 2 | + |
| 3 | +## Supported Comparision Operations |
| 4 | + |
| 5 | +<table> |
| 6 | + <tr> |
| 7 | + <th>= </th> |
| 8 | + <th> != </th> |
| 9 | + <th> < </th> |
| 10 | + <th> > </th> |
| 11 | + <th> <= </th> |
| 12 | + <th> >= </th> |
| 13 | + </tr > |
| 14 | +</table> |
| 15 | + |
| 16 | +## Supported Data Type |
| 17 | + |
| 18 | +<table> |
| 19 | + <tr> |
| 20 | + <th> TYPE </th> |
| 21 | + <th> LENGTH(Byte) </th> |
| 22 | + </tr > |
| 23 | + <tr> |
| 24 | + <th> int整型 </th> |
| 25 | + <th> 4 </th> |
| 26 | + </tr > |
| 27 | + <tr> |
| 28 | + <th> string字符串型 </th> |
| 29 | + <th> 1~MAXLEN </th> |
| 30 | + </tr > |
| 31 | + <tr> |
| 32 | + <th> float浮点型 </th> |
| 33 | + <th> 4 </th> |
| 34 | + </tr > |
| 35 | +</table> |
| 36 | + |
| 37 | +## Installation (Only support Linux) |
| 38 | + |
| 39 | +``` |
| 40 | +git clone git@github.com:Dynmi/WSQL.git |
| 41 | +cd WSQL |
| 42 | +sudo make clean && sudo make all |
| 43 | +``` |
| 44 | + |
| 45 | +## Usage |
| 46 | + |
| 47 | +Use ```./wsql``` to start WSQL. |
| 48 | + |
| 49 | +Each sentence should be ended with ";". |
| 50 | + |
| 51 | +### DML |
| 52 | + |
| 53 | +#### `list databases` |
| 54 | + |
| 55 | +This will list all databases. |
| 56 | + |
| 57 | +#### `create database <database name>` |
| 58 | + |
| 59 | +A new database will be created. |
| 60 | +Example: |
| 61 | +``` |
| 62 | +WSQL > create database dbtest; |
| 63 | +dbtest |
| 64 | +PATH: ./ |
| 65 | +------------SUCCESS------------- |
| 66 | +WSQL > |
| 67 | +``` |
| 68 | + |
| 69 | +#### `drop database <database name>` |
| 70 | + |
| 71 | +Given database will be deleted. |
| 72 | +Example: |
| 73 | +``` |
| 74 | +WSQL > drop database dbtest; |
| 75 | +------------SUCCESS------------- |
| 76 | +WSQL > |
| 77 | +``` |
| 78 | + |
| 79 | +#### `use database <database name>` |
| 80 | + |
| 81 | +This will enter an existing database. |
| 82 | +Example: |
| 83 | +``` |
| 84 | +WSQL > use db2; |
| 85 | +WSQL@db2 > |
| 86 | +``` |
| 87 | + |
| 88 | +#### `list tables` |
| 89 | + |
| 90 | +This will list all tables in a database. |
| 91 | +Example: |
| 92 | +``` |
| 93 | +WSQL@db2 > list tables; |
| 94 | +#==================================# |
| 95 | +| Table | |
| 96 | ++----------------------------------+ |
| 97 | +| tb1 | |
| 98 | +#==================================# |
| 99 | +------------SUCCESS------------- |
| 100 | +WSQL@db2 > |
| 101 | +``` |
| 102 | + |
| 103 | +#### `detail table <table name>` |
| 104 | + |
| 105 | +This will show the details of given table. |
| 106 | +Example: |
| 107 | +``` |
| 108 | +WSQL@db2 > detail table tb1; |
| 109 | +
|
| 110 | + tb1 |
| 111 | +-------------------------------------- |
| 112 | +NAME TYPE LENGTH(Byte) |
| 113 | +-------------------------------------- |
| 114 | +age INT 4 |
| 115 | +name STRING 10 |
| 116 | +-------------------------------------- |
| 117 | +
|
| 118 | +------------SUCCESS------------- |
| 119 | +
|
| 120 | +``` |
| 121 | + |
| 122 | +#### `create table <table name> ...` |
| 123 | + |
| 124 | +A new empty table will be created in database. |
| 125 | +Example: |
| 126 | +``` |
| 127 | +WSQL@db2 > create table tbtest (id INT, height FLOAT, name STRING[12]); |
| 128 | +
|
| 129 | +------------------------------------------ |
| 130 | +CREATING TABLE tbtest |
| 131 | +------------------------------------------ |
| 132 | +./db2/tbtest.scm |
| 133 | +./db2/tbtest.id.data |
| 134 | +./db2/tbtest.id.index |
| 135 | +./db2/tbtest.height.data |
| 136 | +./db2/tbtest.height.index |
| 137 | +./db2/tbtest.name.data |
| 138 | +./db2/tbtest.name.index |
| 139 | +------------SUCCESS------------- |
| 140 | +WSQL@db2 > |
| 141 | +``` |
| 142 | + |
| 143 | +#### `drop table <table name>` |
| 144 | + |
| 145 | +Given table will be deleted. |
| 146 | +Example: |
| 147 | +``` |
| 148 | +WSQL@db2 > drop table tbtest; |
| 149 | +
|
| 150 | +------------------------------------------ |
| 151 | +DROPING TABLE tbtest |
| 152 | +------------------------------------------ |
| 153 | +------------SUCCESS------------- |
| 154 | +WSQL@db2 > |
| 155 | +
|
| 156 | +``` |
| 157 | + |
| 158 | +#### `rename table <table name> <table name>` |
| 159 | + |
| 160 | +Example: |
| 161 | +``` |
| 162 | +WSQL@db2 > list tables; |
| 163 | +#==================================# |
| 164 | +| Table | |
| 165 | ++----------------------------------+ |
| 166 | +| tb1 | |
| 167 | +#==================================# |
| 168 | +------------SUCCESS------------- |
| 169 | +WSQL@db2 > rename table tb1 tbxxx; |
| 170 | +------------SUCCESS------------- |
| 171 | +WSQL@db2 > list tables; |
| 172 | +#==================================# |
| 173 | +| Table | |
| 174 | ++----------------------------------+ |
| 175 | +| tbxxx | |
| 176 | +#==================================# |
| 177 | +------------SUCCESS------------- |
| 178 | +WSQL@db2 > |
| 179 | +``` |
| 180 | + |
| 181 | +#### `clear table <table name>` |
| 182 | + |
| 183 | +#### `alter table <table name> rename column <old column name> <new column name>` |
| 184 | + |
| 185 | +#### `alter table <table name> drop column <column name>` |
| 186 | + |
| 187 | +#### `alter table <table name> add column (<column name> <column type>)` |
| 188 | + |
| 189 | +### DDL |
| 190 | + |
| 191 | +#### `update <table name> (<column name 1>,<column name 2>,...>):(<new value 1>, <new value 2>,...) where <where-condition>` |
| 192 | + |
| 193 | + |
| 194 | +#### `insert into <table name> (<column name 1>,<column name 2>,...):(<new value 1>,<new value 2>,...)` |
| 195 | + |
| 196 | +#### ~~`insert into <table name> select ...`~~ |
| 197 | + |
| 198 | +#### `delete from <table name> where <where-condition>` |
| 199 | + |
| 200 | +#### `select * from <table name>` |
| 201 | +#### `select * from <table name> where <where-condition>` |
| 202 | +#### `select <column name 1>,<column name 2>,... from <table name>` |
| 203 | +#### `select <column name 1>,<column name 2>,... from <table name> where <where-condition>` |
| 204 | + |
| 205 | + |
| 206 | +## Remarks |
| 207 | +- Lastest updated on 5th,March,2021 |
0 commit comments