PostgreSQL和MySQL有不少区别。mysql
建立数据库。(命令相同)sql
mysql>create database testdb1;
查看数据库。数据库
#MySQL(MariaDB) mysql>show databases; #选择数据库testdb mysql>use testdb mysql>select database(); #PostgreSQL \l
重命名数据库名称。(MySQL方法繁琐,本文不贴出具体方法,详见Google搜索。)code
#MySQL #PostgreSQL alter database OldDatabaseName rename to NewDatabaseName;
删除数据库。table
drop database testdb1;
建立表。test
#create database testab1; #\c testdb1 #use testdb1; mysql>create table table1 (id int);
查看表(结构)。select
#MySQL use testdb; #mysql>create table hello (id int); #查看表 mysql>show tables; #查看表结构 mysql>desc hello; mysql>describe hello; mysql>show columns from hello; #PostgreSQL \c testdb #create table hello (id int); \d \d hello
重命名表。(MySQL 还有其余方法。)搜索
#MySQL mysql>rename table OldTableName to NewTableName; #PostgreSQL alter table OldTableName rename to NewTableName.
技巧一则:当MySQL 命令输入错误,虽然能够输入英文;结束命令,但通常会显示错误,这时候咱们能够命令后输入\c,便可结束命令输入,且无报错信息。技巧