Mysql与Postgresql常用命令比较
PostgreSQL |
MySQL |
服务启动: |
服务启动:
MySQL的进程号为1663 |
第一次进入数据库: |
第一次进入数据库: #mysql |
创建用户:(用户Ajian,密码:123) $psql =#create user ajian with password ‘123’ |
创建用户:(用户Ajian,密码:123) (注意:同还可以分配权限,这里是ALL) |
创建数据库(My): #su – postgres $psql =#create database My with owner = ajian template = template1 encoding=’UNICODE’; |
创建数据库(My): 1)#mysql Mysql>create database My; 2)#mysqladmin create My |
查看用户和数据库: #su – postgres $psql =#\l (查看数据库) =#\c 从一个数据库中转到另一个数据库中,如template1=# \c sales 从template1转到sales |
查看用户和数据库: 1)#mysql Mysql>show databases; (看数据库) 2)#mysqlshow use dbname; |
新建用户登录: (首先修改配置文件) # vi /var/lib/pgsql/data/pg_hba.conf(在最后加) host all all 127.0.0.1 255.255.255.255 md5 再重启服务:#service postgresql restart 登录:#psql –h 127.0.0.1 –U ajian My Password: |
新建用户登录: 1)#mysql –u ajian –p (带口令登录) 2)#mysql Mysql>use My; (不带口令登录一般用于本机) |
创建表(employee): =#create table employee( (#employee_id int primary key, (#name char(8), (#sex char(2)); |
创建表: >create table employee( ->employee_id int primary key, ->name char(8), ->sex char(2)); |
查看表: =#\dt |
查看表: >show tables; |
查看表的结构: =#\d employee |
查看表的结构: >sescribe employee; |
向表中添加数据: =#insert into employee values -#(‘1’,’zhang’,’F’); -#(‘2’,’chen’,’M’,); |
向表中添加数据: >insert into employee values ->(‘1’,’zhang’,’F’); ->(‘2’,’chen’,’M’,); |
查看表的数据: =#select * from emlpoyee |
查看表的数据: >select * from emlpoyee; |
创建索引(IN_employee): =#create index IN_employee on employee(name); 查看索引: =#\di 删除索引: =#drop index IN_employee on employee; 重建索引: =#reindex table employee;(重建employee所有的) =#reindex index IN_employee;(重建指定的) |
创建索引(IN_employee): 1)>create index IN_employee on employee(name); 2)>alter table employee add index IN_employee(name); 查看索引: >show index from employee; 删除索引: 1)>drop index IN_employee on employee; 2)>alter table emlpoyee drop index IN_employee; |
删除表: =#drop table employee; |
删除表: >drop table employee; |
删除数据库:(注意命令前面的标志) 1)=#drop database ajian; 2)$dropdb ajian |
删除数据库:(注意命令前面的标志) 1)>drop database ajian; 2)#mysqladmin drop ajian |
原文地址:https://www.cnblogs.com/surplus/p/11406411.html
- 斐波那契数列与IE9
- DateTime.ToString()输出"年/月/日 时:分:秒"的格式
- Flash在线拍摄用户头象
- win7 64位下如何折腾Tubro C 3.0
- TweenLite的又一应用:图片的拼图加载效果
- mysql创建数据表时如何判断是否已经存在?
- 温故知新:接口的隐式实现与显式实现
- 也谈枚举ToString()性能的改进
- silverlight:利用telerik中的zip类对字符串进行压缩、解压
- 索引,视图,存储过程和触发器文档
- 重点解读:用小程序给公众号涨粉10w的7大行业案例
- 网络域名与注册商标冲突的解决途径
- 网站代码优化我们必须要做的那些事
- 真是热闹! Slade.com等多个域名被曝交易
- MySQL 教程
- MySQL 安装
- MySQL 管理与配置
- MySQL PHP 语法
- MySQL 连接
- MySQL 创建数据库
- MySQL 删除数据库
- MySQL 选择数据库
- MySQL 数据类型
- MySQL 创建数据表
- MySQL 删除数据表
- MySQL 插入数据
- MySQL 查询数据
- MySQL where 子句
- MySQL UPDATE 查询
- MySQL DELETE 语句
- MySQL LIKE 子句
- mysql order by
- Mysql Join的使用
- MySQL NULL 值处理
- MySQL 正则表达式
- MySQL 事务
- MySQL ALTER命令
- MySQL 索引
- MySQL 临时表
- MySQL 复制表
- 查看MySQL 元数据
- MySQL 序列 AUTO_INCREMENT
- MySQL 处理重复数据
- MySQL 及 SQL 注入
- MySQL 导出数据
- MySQL 导入数据
- MYSQL 函数大全
- MySQL Group By 实例讲解
- MySQL Max()函数实例讲解
- mysql count函数实例
- MYSQL UNION和UNION ALL实例
- MySQL IN 用法
- MySQL between and 实例讲解
- 文本相似度——编辑距离
- 文本相似度——汉明距离
- python函数——Bunch配置加载
- npm install、npm install --global、npm install --save、npm install --save-dev的区别
- 3种 Springboot 全局时间格式化方式,别再写重复代码了
- pip conda 安装速度慢解决方法
- Linux 中指定使用的GPU
- 未读消息(小红点),前端 与 RabbitMQ 实时消息推送实践,贼简单~
- Day13 :调整数组顺序使奇数位于偶数前面
- TensorFlow 指定GPU 日志却显示的是第0块
- bazel 出现no such package '@org_tensorflow//tensorflow' 错误
- tensorflow API——tf.random_uniform 使用
- go cannot find package "golang.org/x/crypto/ssh/terminal" 解决方案
- go 中的 defer 使用及其规则
- 数据结构算法操作试题(C++/Python/Go)——938 二叉搜索树的范围和