LightDB-创建和删除表
[lightdb@localhost ~]$ ltsql mydb
ltsql (13.8-22.3)
Type "help" for help.
#创建数据表
lightdb@mydb=# CREATE TABLE weather (
city varchar(80),
temp_lo int, -- low temperature
temp_hi int, -- high temperature
prcp real, -- precipitation
date date
);
lightdb@mydb=# CREATE TABLE COMPANY(
ID INT PRIMARY KEY NOT NULL,
NAME TEXT NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR(50),
SALARY REAL
);
lightdb@mydb=# CREATE TABLE cities (
name varchar(80),
location point
);
#列举当前数据库所有表
lightdb@mydb=# \d
List of relations
Schema | Name | Type | Owner
------------+--------------------------------------+----------+---------
lt_catalog | deps_saved_ddl | table | lightdb
.......
public | cities | table | lightdb
public | company | table | lightdb
public | weather | table | lightdb
#查看表详情
lightdb@mydb=# \d company
Table "public.company"
Column | Type | Collation | Nullable | Default
---------+---------------+-----------+----------+---------
id | integer | | not null |
name | text | | not null |
age | integer | | not null |
address | character(50) | | |
salary | real | | |
Indexes:
"company_pkey" PRIMARY KEY, btree (id)
lightdb@mydb=# \d weather
Table "public.weather"
Column | Type | Collation | Nullable | Default
---------+-----------------------+-----------+----------+---------
city | character varying(80) | | |
temp_lo | integer | | |
temp_hi | integer | | |
prcp | real | | |
date | date | | |
lightdb@mydb=# \d cities
Table "public.cities"
Column | Type | Collation | Nullable | Default
----------+-----------------------+-----------+----------+---------
name | character varying(80) | | |
location | point | | |
#删除表
lightdb@mydb=# drop table company;
DROP TABLE
lightdb@mydb=# \d
List of relations
Schema | Name | Type | Owner
------------+--------------------------------------+----------+---------
lt_catalog | deps_saved_ddl | table | lightdb
......
public | weather | table | lightdb