OushuDB 基本用法 创建数据库和表
发布时间:2023-02-10 14:25:49 所属栏目:MySql教程 来源:
导读: changlei:build ChangLei$ psql -d postgres
psql (8.2.15)
Type "help" for help.
postgres=# create database test; # 创建数据库test
CREATE DATABASE
postgres=#
psql (8.2.15)
Type "help" for help.
postgres=# create database test; # 创建数据库test
CREATE DATABASE
postgres=#
|
changlei:build ChangLei$ psql -d postgres psql (8.2.15) Type "help" for help. postgres=# create database test; # 创建数据库test CREATE DATABASE postgres=# \c test # 连接进入test数据库 You are now connected to database "test" as user "ChangLei". test=# create table foo(id int, name varchar); # 创建表foo CREATE TABLE test=# \d # 显示当前数据库test中所有表 List of relations Schema | Name | Type | Owner | Storage --------+------+-------+----------+------------- public | foo | table | ChangLei | append only (1 row) test=# insert into foo values(1, 'hawq'),(2, 'hdfs'); INSERT 0 2 test=# select * from foo; # 从表foo中选择数据 id | name ----+------ 1 | hawq 2 | hdfs (2 rows) 如果想删除表或者数据库的话可以使用drop语句。 test=# drop table foo; DROP TABLE test=# \d No relations found. test=# drop database test; # 因为现在在test数据库中创建数据库表,所以不能删除 ERROR: cannot drop the currently open database test=# \c postgres # 首先连接到postgres数据库,然后删除test数据库 You are now connected to database "postgres" as user "ChangLei". postgres=# drop database test; DROP DATABASE (编辑:我爱资讯网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
站长推荐


