PostgreSQL数据库

2023-10-27

0 安装

我使用的操作系统为Ubuntu。
安装命令:

sudo apt-get update
sudo apt-get install postgresql postgresql-client

进入postgres:

sudo -i -u postgres
psql

退出命令:

\q

PostgreSQL启动服务等:

sudo /etc/init.d/postgresql start # 开启
sudo /etc/init.d/postgresql stop # 关闭
sudo /etc/init.d/postgresql restart # 重启

安装pgAdmin4.

  1. 首先安装公钥

curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add

  1. 更新源

sudo sh -c ‘echo “deb [https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/ ( l s b r e l e a s e ] ( h t t p s : / / f t p . p o s t g r e s q l . o r g / p u b / p g a d m i n / p g a d m i n 4 / a p t / (lsb_release](https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/ (lsbrelease](https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/(lsb_release) -cs) pgadmin4 main” > /etc/apt/sources.list.d/pgadmin4.list && apt update’

  1. 安装pgAdmin4

sudo apt install pgadmin4

  1. pdAdmin4-web

sudo apt install pgadmin4-web

  1. 最后执行

sudo /usr/pgadmin4/bin/setup-web.sh

1 数据类型

http://www.postgres.cn/docs/12/datatype.html

  • 数值类型
    | 名字 | 存储长度 | 描述 | 范围 |
    | — | — | — | — |
    | smallint | 2 字节 | 小范围整数 | -32768 到 +32767 |
    | integer | 4 字节 | 常用的整数 | -2147483648 到 +2147483647 |
    | bigint | 8 字节 | 大范围整数 | -9223372036854775808 到 +9223372036854775807 |
    | decimal | 可变长 | 用户指定的精度,精确 | 小数点前 131072 位;小数点后 16383 位 |
    | numeric | 可变长 | 用户指定的精度,精确 | 小数点前 131072 位;小数点后 16383 位 |
    | real | 4 字节 | 可变精度,不精确 | 6 位十进制数字精度 |
    | double precision | 8 字节 | 可变精度,不精确 | 15 位十进制数字精度 |
    | smallserial | 2 字节 | 自增的小范围整数 | 1 到 32767 |
    | serial | 4 字节 | 自增整数 | 1 到 2147483647 |
    | bigserial | 8 字节 | 自增的大范围整数 | 1 到 9223372036854775807 |

  • 货币类型

money 类型存储带有固定小数精度的货币金额。
numeric、int 和 bigint 类型的值可以转换为 money,不建议使用浮点数来处理处理货币类型,因为存在舍入错误的可能性。

名字 存储容量 描述 范围
money 8 字节 货币金额 -92233720368547758.08 到 +92233720368547758.07
  • 字符类型
  • 日期/时间类型
  • 布尔类型
  • 枚举类型

枚举类型是一个包含静态和值的有序集合的数据类型。
PostgtesSQL中的枚举类型类似于 C 语言中的 enum 类型。
与其他类型不同的是枚举类型需要使用 CREATE TYPE 命令创建。

CREATE TYPE mood AS ENUM (‘sad’, ‘ok’, ‘happy’);

创建一周中的几天,如下所示:

CREATE TYPE week AS ENUM (‘Mon’, ‘Tue’, ‘Wed’, ‘Thu’, ‘Fri’, ‘Sat’, ‘Sun’);

就像其他类型一样,一旦创建,枚举类型可以用于表和函数定义。

  • 几何类型
  • 网络地址类型

PostgreSQL 提供用于存储 IPv4 、IPv6 、MAC 地址的数据类型。
用这些数据类型存储网络地址比用纯文本类型好, 因为这些类型提供输入错误检查和特殊的操作和功能。

  • 位串类型
  • 文本搜索类型
  • UUID 类型
  • XML 类型

创建XML值
使用函数 xmlparse: 来从字符数据产生 xml 类型的值:

XMLPARSE (DOCUMENT ‘<?xml version="1.0"?>

Manual…’) XMLPARSE (CONTENT ‘abcbarfoo’)
  • JSON 类型
  • 数组类型

2 创建表

  • 创建数据库

首先创建数据库,如下所示:

postgres=# create database example;
CREATE DATABASE
postgres=# \l
postgres=# \c example
You are now connected to database “example” as user “postgres”.
example=#

创建数据库:create database example;
连接其它数据库:\c example;
删除数据库:drop database example;

  • 创建数据表

创建表:

create table_name(
Column_name data_type constraints
);

查询表:\d personl;(\dt只显示表)
删除表:drop table person;
WindTerm_Eq2SKFEuO3.png
:::success
example=# create table person(
id bigserial not null primary key,
name varchar(200) not null,
gender varchar(7) not null,
birthday date not null,
email varchar(250));
CREATE TABLE
example=# \d
List of relations
Schema | Name | Type | Owner
--------±--------------±---------±---------
public | person | table | postgres
public | person_id_seq | sequence | postgres
(2 rows)

example=# \d person_
person_id_seq person_pkey
example=# \d person_
person_id_seq person_pkey
example=# \d person_id_seq
Sequence “public.person_id_seq”
Type | Start | Minimum | Maximum | Increment | Cycles? | Cache
--------±------±--------±--------------------±----------±--------±------
bigint | 1 | 1 | 9223372036854775807 | 1 | no | 1
Owned by: public.person.id

example=# \d person
example=# \d person;
example=#
:::

2 插入数据

  • 查询

查询语句

select (column_name)/* from table_name;

插入语句

insert into table_name(column_name,…) values(‘column_value’,…);

example=# select * from person;
 id | name | gender | birthday | email 
----+------+--------+----------+-------
(0 rows)

example=# insert into person (name, gender, birthday)values('dashabi','male','12-11-3')
example-# select * from person;
ERROR:  syntax error at or near "select"
第2行select * from person;
     ^
example=# select * from person;
 id | name | gender | birthday | email 
----+------+--------+----------+-------
(0 rows)

example=# insert into person (name, gender, birthday)values('dashabi','male','12-11-3');
INSERT 0 1
example=# select * from person;
 id |  name   | gender |  birthday  | email 
----+---------+--------+------------+-------
  1 | dashabi | male   | 2012-11-03 | 
(1 row)

example=# insert into person (name, gender, birthday)values('chsihi','male',date'12-11-3','ahha@131.com');
ERROR:  INSERT has more expressions than target columns
第1行...er, birthday)values('chsihi','male',date'12-11-3','ahha@131....
                                                          ^
example=# insert into person (name, gender, birthday,mail)values('chsihi','male',date'12-11-3','ahha@131.com');
ERROR:  column "mail" of relation "person" does not exist
第1行insert into person (name, gender, birthday,mail)values('chsi...
                                                ^
example=# \d person;
example=# insert into person (name, gender, birthday,email)values('chsihi','male',date'12-11-3','ahha@131.com');
INSERT 0 1
example=# \d person;
example=# select * from person;
 id |  name   | gender |  birthday  |    email     
----+---------+--------+------------+--------------
  1 | dashabi | male   | 2012-11-03 | 
  2 | chsihi  | male   | 2012-11-03 | ahha@131.com
(2 rows)

example=# 

4 查询语句

4.1 mock数据

mock构造数据集。
chrome_dpaz1poR7Y.png
https://mockaroo.com/
:::tips
postgres=# create database mockdb;
CREATE DATABASE
postgres=# \c mockdb ;
You are now connected to database “mockdb” as user “postgres”.
mockdb=# \i /home/day3/person.sql
:::

4.2 查询

升序降序。
:::tips
mockdb=# select * from person order by id asc;
mockdb=# select * from person order by id desc;
:::
去重。
:::tips
mockdb=# select distinct birth_country from person order by birth_country;
:::
where,and和or。
:::tips
mockdb=# select * from person where gender=‘Male’;
mockdb=# select * from person where gender=‘Male’ and birth_country=‘China’;
mockdb=# select * from person where gender=‘Male’ and (birth_country=‘China’ or birth_country=‘Poland’);
mockdb=#
:::
比较。

mockdb=# select 1=1;
?column?

t
(1 row)
mockdb=# select 1>1;
?column?

f
(1 row)
mockdb=# select 1<>2;
?column?

t
(1 row)
mockdb=# select ‘a’ > ‘b’;
?column?

f
(1 row)

:::tips
mockdb=# select * from person limit 10;
id | name | email | gender | birthday | birth_country
----±--------------------±---------------------------±------------±-----------±--------------
1 | Neville Catcheside | ncatcheside0@amazon.co.uk | Male | 1995-07-30 | Poland
2 | Pincus Jirus | pjirus1@mapy.cz | Male | 2017-10-08 | Portugal
3 | Flo Lanning | flanning2@mashable.com | Genderfluid | 2018-09-27 | Indonesia
4 | Giulio Eccleshall | geccleshall3@123-reg.co.uk | Male | 2004-09-24 | Serbia
5 | Dorothee Dunmore | | Female | 2018-03-08 | China
6 | Sinclair Giacometti | sgiacometti5@who.int | Male | 2001-12-09 | Philippines
7 | Adolphus Relf | arelf6@psu.edu | Agender | 2001-05-26 | South Africa
8 | Mattias Aloigi | maloigi7@miibeian.gov.cn | Male | 2014-07-11 | Greece
9 | Elsworth Hadfield | ehadfield8@google.com.hk | Male | 2006-02-13 | United States
10 | Fancy Lundon | | Female | 2010-02-27 | China
(10 rows)
mockdb=# select * from person limit 20;
id | name | email | gender | birthday | birth_country
----±--------------------±------------------------------±------------±-----------±--------------
1 | Neville Catcheside | ncatcheside0@amazon.co.uk | Male | 1995-07-30 | Poland
2 | Pincus Jirus | pjirus1@mapy.cz | Male | 2017-10-08 | Portugal
3 | Flo Lanning | flanning2@mashable.com | Genderfluid | 2018-09-27 | Indonesia
4 | Giulio Eccleshall | geccleshall3@123-reg.co.uk | Male | 2004-09-24 | Serbia
5 | Dorothee Dunmore | | Female | 2018-03-08 | China
6 | Sinclair Giacometti | sgiacometti5@who.int | Male | 2001-12-09 | Philippines
7 | Adolphus Relf | arelf6@psu.edu | Agender | 2001-05-26 | South Africa
8 | Mattias Aloigi | maloigi7@miibeian.gov.cn | Male | 2014-07-11 | Greece
9 | Elsworth Hadfield | ehadfield8@google.com.hk | Male | 2006-02-13 | United States
10 | Fancy Lundon | | Female | 2010-02-27 | China
11 | Angel Epine | aepinea@time.com | Male | 2003-03-08 | Russia
12 | Clayson Darke | | Male | 2013-05-05 | China
13 | Crosby Plane | cplanec@cafepress.com | Polygender | 2012-02-26 | Russia
14 | Emmy Grocutt | | Female | 2006-09-05 | Luxembourg
15 | Dianemarie Edgson | dedgsone@comsenz.com | Female | 2014-05-10 | China
16 | Rollins Sporrij | rsporrijf@oaic.gov.au | Male | 2014-09-15 | Peru
17 | Mattheus Gawkroge | | Male | 2012-01-23 | Greece
18 | Cody Bwye | cbwyeh@deliciousdays.com | Male | 1995-12-22 | Tajikistan
19 | Gal Benditt | gbenditti@google.ru | Male | 2001-02-13 | Morocco
20 | Debbie Tregiddo | dtregiddoj@barnesandnoble.com | Female | 2016-04-23 | Belarus
(20 rows)
mockdb=# select * from person offest 10 limit 20;
ERROR: syntax error at or near “10”
第1行select * from person offest 10 limit 20;
^
mockdb=# select * from person offset 10 limit 20;
id | name | email | gender | birthday | birth_country
----±------------------±------------------------------±-----------±-----------±--------------
11 | Angel Epine | aepinea@time.com | Male | 2003-03-08 | Russia
12 | Clayson Darke | | Male | 2013-05-05 | China
13 | Crosby Plane | cplanec@cafepress.com | Polygender | 2012-02-26 | Russia
14 | Emmy Grocutt | | Female | 2006-09-05 | Luxembourg
15 | Dianemarie Edgson | dedgsone@comsenz.com | Female | 2014-05-10 | China
16 | Rollins Sporrij | rsporrijf@oaic.gov.au | Male | 2014-09-15 | Peru
17 | Mattheus Gawkroge | | Male | 2012-01-23 | Greece
18 | Cody Bwye | cbwyeh@deliciousdays.com | Male | 1995-12-22 | Tajikistan
19 | Gal Benditt | gbenditti@google.ru | Male | 2001-02-13 | Morocco
20 | Debbie Tregiddo | dtregiddoj@barnesandnoble.com | Female | 2016-04-23 | Belarus
21 | Gillian Daville | gdavillek@liveinternet.ru | Female | 1998-09-25 | Russia
22 | Marven Cahill | mcahilll@g.co | Male | 1995-03-15 | China
23 | Arlyn Manicomb | amanicombm@goo.gl | Female | 2014-06-27 | China
24 | Stefania Bootes | | Female | 1995-03-27 | Azerbaijan
25 | Edan Yann | eyanno@narod.ru | Male | 2001-02-10 | Japan
26 | Garfield Lago | glagop@dmoz.org | Male | 2016-03-21 | China
27 | Abraham Petren | apetrenq@wordpress.com | Male | 2006-12-15 | China
28 | Merell Cranna | | Male | 2010-03-08 | Japan
29 | Kev Olorenshaw | kolorenshaws@1und1.de | Male | 2022-02-07 | Russia
30 | Elli Roman | eromant@tripadvisor.com | Female | 1996-09-05 | Jamaica
(20 rows)
mockdb=#
:::
like和ilike

mockdb=# select * from person where name like ‘%ll’;
mockdb=# select * from person where name like ‘__ll’;
id | name | email | gender | birthday | birth_country
----±-----±------±-------±---------±--------------
(0 rows)

mockdb=# select * from person where name like ‘___ll’;
id | name | email | gender | birthday | birth_country
----±-----±------±-------±---------±--------------
(0 rows)

mockdb=# select * from person where name like ‘____ll’;
id | name | email | gender | birthday | birth_country
----±-----±------±-------±---------±--------------
(0 rows)

mockdb=# select * from person where name like ‘_____ll’;
id | name | email | gender | birthday | birth_country
----±-----±------±-------±---------±--------------
(0 rows)

mockdb=# select * from person where name like ‘%ll’;
mockdb=# select * from person where name like ‘__________ll’;
id | name | email | gender | birthday | birth_country
-----±-------------±---------------------±-------±-----------±--------------
158 | Erin Gostall | egostall4d@google.ca | Male | 2020-01-17 | Argentina
825 | Glen Snoxall | gsnoxallmw@go.com | Male | 2006-04-08 | Indonesia
(2 rows)

mockdb=# select * from person where birth_country like ‘J%’;
id | name | email | gender | birthday | birth_country
-----±------------------±---------------------------±-------±-----------±--------------
25 | Edan Yann | eyanno@narod.ru | Male | 2001-02-10 | Japan
28 | Merell Cranna | | Male | 2010-03-08 | Japan
30 | Elli Roman | eromant@tripadvisor.com | Female | 1996-09-05 | Jamaica
115 | Alvie Hannay | ahannay36@1688.com | Male | 2018-05-18 | Jordan
147 | Terrell Chimenti | tchimenti42@discovery.com | Male | 2016-05-13 | Japan
151 | Merci Albon | malbon46@zimbio.com | Female | 1997-05-27 | Japan
278 | Yankee Ecclesall | | Male | 2008-11-03 | Japan
286 | Marsiella Sillett | msillett7x@miibeian.gov.cn | Female | 1997-04-05 | Japan
319 | Lilla Rasch | lrasch8u@earthlink.net | Female | 2019-11-28 | Jordan
426 | Siward Ablewhite | | Male | 2021-01-09 | Japan
430 | Avivah Leivesley | aleivesleybx@pbs.org | Female | 2010-02-01 | Japan
549 | Georgeta Borit | gboritf8@mediafire.com | Female | 2012-07-23 | Japan
565 | Dasie Moehler | dmoehlerfo@prnewswire.com | Female | 1995-10-21 | Japan
623 | Jenica D’Onise | jdoniseha@fda.gov | Female | 2000-08-14 | Japan
746 | Murry Moulster | mmoulsterkp@example.com | Male | 2005-01-10 | Japan
868 | Lanita Mitrovic | lmitrovico3@elpais.com | Female | 1998-03-21 | Japan
871 | Osgood Bemlott | | Male | 1993-09-15 | Japan
878 | Jennine Gianelli | jgianelliod@twitter.com | Female | 2014-11-25 | Japan
934 | Julian Acres | jacrespx@mashable.com | Male | 2002-12-25 | Japan
975 | Dorian Howieson | dhowiesonr2@squidoo.com | Female | 2018-03-22 | Japan
(20 rows)

mockdb=# select * from person where birth_country like ‘j%’;
id | name | email | gender | birthday | birth_country
----±-----±------±-------±---------±--------------
(0 rows)

mockdb=# select * from person where birth_country ilike ‘j%’;
id | name | email | gender | birthday | birth_country
-----±------------------±---------------------------±-------±-----------±--------------
25 | Edan Yann | eyanno@narod.ru | Male | 2001-02-10 | Japan
28 | Merell Cranna | | Male | 2010-03-08 | Japan
30 | Elli Roman | eromant@tripadvisor.com | Female | 1996-09-05 | Jamaica
115 | Alvie Hannay | ahannay36@1688.com | Male | 2018-05-18 | Jordan
147 | Terrell Chimenti | tchimenti42@discovery.com | Male | 2016-05-13 | Japan
151 | Merci Albon | malbon46@zimbio.com | Female | 1997-05-27 | Japan
278 | Yankee Ecclesall | | Male | 2008-11-03 | Japan
286 | Marsiella Sillett | msillett7x@miibeian.gov.cn | Female | 1997-04-05 | Japan
319 | Lilla Rasch | lrasch8u@earthlink.net | Female | 2019-11-28 | Jordan
426 | Siward Ablewhite | | Male | 2021-01-09 | Japan
430 | Avivah Leivesley | aleivesleybx@pbs.org | Female | 2010-02-01 | Japan
549 | Georgeta Borit | gboritf8@mediafire.com | Female | 2012-07-23 | Japan
565 | Dasie Moehler | dmoehlerfo@prnewswire.com | Female | 1995-10-21 | Japan
623 | Jenica D’Onise | jdoniseha@fda.gov | Female | 2000-08-14 | Japan
746 | Murry Moulster | mmoulsterkp@example.com | Male | 2005-01-10 | Japan
868 | Lanita Mitrovic | lmitrovico3@elpais.com | Female | 1998-03-21 | Japan
871 | Osgood Bemlott | | Male | 1993-09-15 | Japan
878 | Jennine Gianelli | jgianelliod@twitter.com | Female | 2014-11-25 | Japan
934 | Julian Acres | jacrespx@mashable.com | Male | 2002-12-25 | Japan
975 | Dorian Howieson | dhowiesonr2@squidoo.com | Female | 2018-03-22 | Japan
(20 rows)

group by。

mockdb=# select birth_country, count() from person group by birth_country;
mockdb=# select birth_country, count(
) from person group by birth_country having count(*) > 20;
birth_country | count
---------------±------
Indonesia | 112
Sweden | 28
Portugal | 40
France | 22
Philippines | 54
China | 182
Russia | 59
Brazil | 44
Poland | 35
(9 rows)

mockdb=#

删除。

delete from person where id = 1

chrome_qzg6Ha9U36.png
chrome_EN6dECnfOw.png
chrome_M6Fp5QRQtZ.png

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

PostgreSQL数据库 的相关文章

随机推荐

  • 刷脸支付会员积分卡券打造完整商业闭环

    刷脸支付成为新的支付趋势的原因 缓解对外部媒介的过渡依赖 移动支付的过程需要手机 而很多消费者会遇到手机没电或者忘记携带手机的情况 而刷脸支付不需要手机 仅通过人脸识别就可以完成付款 随着支付宝 微信 央行都推出了自己的刷脸支付设备 刷脸支
  • VS2017调节字体大小快捷键

    快捷键 Ctrl Shift gt 调大 Ctrl Shift lt 调小 Ctrl 鼠标滚动 向上调大 向下调小 笔记本触屏放大 就和在手机上放大图片一样 也可以去工具 gt 选项 gt 环境 gt 字体与颜色里面直接选择字号调整
  • 【廖雪峰python入门笔记】list_创建

    1 list 列表 list 1 是Python内置的一种数据类型 2 是一种有序的集合 3 可以随时添加和删除其中的元素 比如 列出班里所有同学的名字 就可以用一个list表示 Michael Bob Tracy list是数学意义上的有
  • GraalVM原生编译,Swing取色调色工具

    Graalvm 安装和静态编译 今天使用GraalVM把以前写的一个Swing小工具ColorCat转成原生应用 使用GraalVM转成原生应用后 可以脱离JVM CPU和内存的占用率是降低了的 性能是相对提升了不少 GraalVM编译步骤
  • SVN提交代码评审

    1 前言 在公司提交代码时 需要发给上级主管评审 如何让评审的主管能快速清晰的知道你的修改点是很重要也是很基础的要求 有的是用用脚本来产生差异文件的文件夹 但其实SVN本身就有命令列出当前修改和版本的差异点 2 命令 svn commit
  • 登录页面中记住密码操作的实现

    1 思路 访问 前端login jsp gt 后台 如果上次用户选择勾选记住密码 自动填充账号和密码 否则 不填 如何判断上次是否记住密码 第一次登录成功 去判断是否需要记住密码 如果需要记住密码 则往浏览器写cookie 否则 删除coo
  • Swift Property ‘self.xxx‘ not initialized at super.init call

    Swift重写父类的init方法时 报了如下错误 Property self xxx not initialized at super init call 大概意思是在调用父类init方法前 需要给属性赋值 报错代码 required in
  • QT 自定义widget 背景图片设置

    在自定义widget中 通过setSheetStyle 设置的背景图片没有效果 必须加一层QFrame 定义一个QFrame 设置QFrame的 sheetstyle 同时设置 widget setAutoFillBackground tr
  • 使用python-docx在文档中插入图片

    在文档中添加图片的方法如下 from docx import Document from docx shared import Inches Cm document Document document add heading 大标题 0 新
  • VUE 中let that = this 或者 var that = this 有什么意义

    在vue 开发过程中我们经常会发现 let that this 这样写有什么好处呢 首先要理解this 下面简述两点 1 this 永远指向一个对象 2 this 的指向取决于函数调用的位置 首先 this 指向的是一个对象 这个好理解 难
  • 回归分析结果表格怎么填_Excel回归分析结果的详细阐释

    内容来自用户 jasonboy95 利用Excel的数据分析进行回归 可以得到一系列的统计参量 下面以连续10年积雪深度和灌e69da5e887aa3231313335323631343130323136353331333433646365
  • 永年二中2021高考成绩查询,喜讯丨邯郸市永年二中今年高考成绩再创历史新高...

    很多朋友在关注 喜讯丨邯郸市永年二中今年高考成绩再创历史新高 下面带大家一起来阅读吧 近10年高考县状元 2004年全县理科状元 王延涛 南沿村镇西王庄村 七中 2005年全县文科状元 刘 鑫 广府镇西街 九中 全县理科状元 杨佩勋 东杨庄
  • 帮我写一下目标检测的代码

    您好 我可以为您提供以下基本的目标检测代码 import cv2 读取图像 img cv2 imread image jpg 创建一个检测器 detector cv2 CascadeClassifier detector xml 检测目标
  • springboot整合redis 使用缓存注解

    1 启动类标明 EnableCaching SpringBootApplication MapperScan com jx luckyDraw mapper EnableCaching public class LuckyDrawAppli
  • Java中 Long(long) 和Integer(int)之间的强制转换

    一 将long型转化为int型 这里的long型是基础类型 long a 10 int b int a 二 将Long型转换为int 型的 这里的Long型是包装类型 Long a 10 int b a intValue 三 将int型转化
  • Spring Boot + Disruptor

    首先了解一下Disrupto的背景 Disruptor 是英国外汇交易公司LMAX开发的一个高性能队列 研发的初衷是解决内存队列的延迟问题 在性能测试中发现竟然与I O操作处于同样的数量级 基于 Disruptor 开发的系统单线程能支撑每
  • linux学习——awk ‘{print $2}‘ 这个命令是什么意思?

    2 表示第二个字段 print 2 打印第二个字段 awk print 2 fileName 一行一行的读取指定的文件 以空格作为分隔符 打印第二个字段 比如有这样一个文件 a1 b1 c1 d1 a2 b2 c2 d2 执行的结果是 输出
  • 工信部印发互联网+行动计划 聚焦智能制造

    工信部印发 工业和信息化部关于贯彻落实 lt 国务院关于积极推进 互联网 行动的指导意见 gt 的行动计划 2015 2018年 意见提出总体目标 到2018年 互联网与制造业融合进一步深化 制造业数字化 网络化 智能化水平显著提高 其中提
  • 使用正则去掉html标签

    在开发项目的时候 会有去掉html标签只提取文字内容的情况 在此做个记录 以免之后找不到 1 匹配 lt 开始 gt 结束的全局正则 var regex lt gt gt ig 2 body内部的p标签 body p 我是文本内容 p 3
  • PostgreSQL数据库

    0 安装 我使用的操作系统为Ubuntu 安装命令 sudo apt get update sudo apt get install postgresql postgresql client 进入postgres sudo i u post