postgresql语句结构
数据库postgresql区分大小写,在使用可视化
软件操作该数据库时,一定注意大小写,关键
字段,一定要使用双引号。(包括在开发软件中)
使用psql命令行登录数据库需要一些参数,
如psql -h localhost -U postgres -的postgres -p 5432,
如果在dos下直接使用psql无需另带参数时,需要添加几个环境变量,
PGHOST=localhost
PGPORT=5432
PGUSER=postgres
这样配置后直接使用psql后只需要输入密码就可以了。
————————————————————————————————
在windows的dos窗口连接数据库, 默认的用户和数据库是postgres
psql -U user -d dbname
1.新建数据库
create database 数据库名;
2.查询数据库(或者说列举数据库,相当于mysql的“show databases;")
\l
3.切换数据库,相当于mysql的“use 数据库名;”
\c 数据库名;
4.删除数据库
drop database [数据库名];
5.创建一个表
create table mytable3(
id serial primary key,
username text,
password text,
age integer,
birthday date,
computerBrand text,
computerPrice numeric,
recordAutoDate ti