MySql 和 PostGres 对照表
初始化数据库
$prefix/bin/mysql_install_db --ldata=XXX--user=mysql
mkdir XXX; $prefix/bin/initdb [-D $prefix/wdb] -WXXX
启动|停止 数据库服务器
$prefix/share/mysql/mysql.server start|stop
pg_ctl -w -D XXX -l $prefix/wdb/xpg_logstart|stop
进入命令行
# mysql
# psql postgres
添加用户
mysql$ grant all privileges on *.* to zhangsan@"%" identified by"123"
postgres=# create user ajian with password‘123’
以某用户身份进入命令行
# mysql -u zhangsan -p
# psql -h 127.0.0.1 -U zhangsan YYY
创建数据库
mysql$ create database YYY;
postgres=# create database YYY
显示数据库
mysql$ show databases;
postgres=# \l
创建表
mysql$ Create table employee(employee_id int primary key, namechar(8), sex char(2));
postgres=# create table employee(employee_id int primary key, namechar(8), sex char(2));
显示数据表
mysql$ show tables;
postgres=# \dt
显示表结构
mysql$ describe employee;
postgres=# \d employee
插入记录
mysql$ insert into employeevalues('1','zhang','F');
postgres=# insert into employeevalues('1','zhang','F');
显示记录
mysql$ select * fromemployee;
postgres=# select * fromemployee;
删除记录
mysql$ delete from employee whereemployee_id='3';
postgres=# delete from employee whereemployee_id='3';
删除表
mysql$ drop tableemployee;
postgres=# drop tableemployee;
删除数据库
mysql$ drop database YYY;
postgres=# drop databaseYYY;
切换数据库
mysql$ use YYY;
postgres=# \c YYY