zrxJuly's Blog

成长中的产品媛


  • Home

  • Tags

  • Categories

  • Archives

  • About

  • Search

PostgreSQL学习笔记(一)——PostgreSQL介绍

Posted on 2018-09-25 | In PostgreSQL |

PostgreSQL介绍

PostgreSQL是一个开源对象关系数据库管理系统(ORDBMS);用于安全地存储数据;支持最佳做法,并允许在处理请求时检索它们。PostgreSQL是跨平台的,可以在许多操作系统上运行。

PostgreSQL特点:

  • 可在所有主要操作系统上运行;
  • PostgreSQL支持文本、图像、声音和视频,并包括用于C/C++,Java,Python,Ruby和开发数据库链接(ODBC)的编程接口。
  • PostgreSQL支持SQL的许多功能,例如复杂SQL查询,SQL子选择,外键,触发器,视图,事务,多进程并发控制(MVCC),流式复制,热备。
  • 在PostgreSQL中,表可以设置为从“父”表继承其特性
  • 可以安装多个扩展以向PostgreSQL添加附加功能。

PostgreSQL数据类型

数据类型 指定要在表字段中存储哪种类型的数据。在创建表时,对于每列必须使用数据类型。
三种主要的数据类型:

  • 数值
  • 字符串
  • 日期/时间

数值数据类型

数字数据类型用于指定表中的数字数据。

名称 描述 存储大小
smallint 存储整数,小范围 2字节
integer 存储整数,使用这个类型可存储典型的整数 4字节
bigint 存储整数,大范围 8字节
decimal 用户指定的精度,精确 变量
numeric 用户指定的精度,精确 变量
real 可变精度,不精确 4字节
double 可变精度,不精确 8字节
serial 自动递增整数 4字节
bigserial 达到自动递增整数 8字节
Read more »

LeetCode之数据结构——数组demo2

Posted on 2018-09-01 | In 数据结构 , LeetCode |

data structure picture

Coding Question:
In a given integer array nums, there is always exactly one largest element.
Find whether the largest element in the array is at least twice as much as every other number in the array.
If it is, return the index of the largest element, otherwise return -1.
编程题:
给定一个数组,总是存在一个最大元素。查找数组中的最大元素,该元素是否至少是数组中其他每个元素的两倍。如果是,返回最大元素的索引,否则返回-1。
思路:

  • 首先,将给定数组中最大的元素查询出来
  • 然后,遍历数组中的元素,比较数组中最大元素是否大于或等于除最大元素的其他每个元素的两倍
Read more »

LeetCode之数据结构——数组

Posted on 2018-08-21 | In 数据结构 , LeetCode |

data structure picture

从今天开始刷LeetCode,目标:每周至少刷一个Coding Question,出一篇data structure学习博文进行总结。Fighting!
解出的代码案例也都会在我的GitHub上进行维护。如果觉得对您有帮助,欢迎star or fork~
附上GitHub项目地址:https://github.com/zrxJuly/dataStructure。
本文首发于我的个人博客:zrxJuly’s Blog,欢迎访问,Let’s study together.

数组简介

  数组是数据结构中的基本模块之一,因为字符串是由字符数组形成的,所以二者是相似的。
数组是一种基本的数据结构,用于按顺序存储元素集合,数组中的每个元素都可以通过数组索引来识别,元素可以随机存取。数组可以有一个或多个维度,
   一维数组:也叫线性数组。数组具有固定的容量,我们需要在初始化时指定数组的大小。然而这种在初始化时指定数组大小的方法会很不方便甚至可能会造成浪费。

Read more »

Redis系列(三)——Redis键命令(key)

Posted on 2018-08-18 | In Redis |

blog picture

Redis 键命令用于管理Redis的键。

语法:

1
command keyName

以下列举部分常用的Redis键命令:

DEL key

删除已存在的key。不存在的key则会被忽略。

语法:

1
DEL keyName

返回值:被删除key的数量。
例:

1
2
3
4
5
6
7
8
127.0.0.1:6379> set name "zrx"
OK
127.0.0.1:6379> get name
"zrx"
127.0.0.1:6379> del name
(integer) 1
127.0.0.1:6379> get name
(nil)

DUMP key

序列化给定的key并返回序列化之后的值。

1
2
3
4
5
6
127.0.0.1:6379> set name zrxJuly
OK
127.0.0.1:6379> get name
"zrxJuly"
127.0.0.1:6379> dump name
"\x00\azrxJuly\t\x00\\\xb5\xa0\xd4;wR\xbf"

EXISTS key

用于检查指定的key是否存在。

语法:

1
EXISTS keyName

返回值:key存在返回1,否则返回0。
例:

1
2
3
4
5
6
7
8
127.0.0.1:6379> set name "a"
OK
127.0.0.1:6379> exists name
(integer) 1
127.0.0.1:6379> del name
(integer) 1
127.0.0.1:6379> exists name
(integer) 0
Read more »

Redis系列(二)——Redis数据类型

Posted on 2018-08-17 | In Redis |

Redis picture
Redis支持5种数据类型:

  • string:字符串
  • hash:哈希
  • list:列表
  • set: 集合
  • zset:有序集合(sorted set)

String:字符串

概念及基本用法

string是Redis最基本的类型,一个key对应一个value;
string类型是二进制安全的,即Redis的string可包含任何数据。比如jpg图片或者序列化的对象。
string类型是Redis最基本的数据类型,string类型的值最大能存储512MB。

语法格式:
set key value
get key

1
2
3
4
127.0.0.1:6379> set name 'zrx'
OK
127.0.0.1:6379> get name
"zrx"

Redis 命令不区分大小写,记录的数据是区分大小写的。上面例子 键为name,值为zrx。使用了set先给name赋值为’zrx’,再使用了get取键对应的值。通常用SET command和GET command来设置和获取字符串值。

Read more »
1234
阿媛Erin

阿媛Erin

愿有前程可奔赴,亦有岁月可回首

20 posts
14 categories
17 tags
RSS
GitHub CSDN E-Mail Weibo
Links
  • crossoverJie's Blog
  • 我在北纬36°
© 2018 — 2020 阿媛Erin
Powered by Hexo
|
Theme — NexT.Pisces