Postgresql 洛雷姆是什么意思?

Postgresql 洛雷姆是什么意思?,postgresql,Postgresql,我在PSQL中执行以下代码: begin; create schema if not exists sandbox; create table sandbox.category ( id serial primary key, name text not null ); insert into sandbox.category(name) values ('sport'),('news'),('box office'),('music'); create

我在PSQL中执行以下代码:

begin;

create schema if not exists sandbox;

create table sandbox.category
 (
   id    serial primary key,
   name  text not null
 );

insert into sandbox.category(name)
     values ('sport'),('news'),('box office'),('music');

create table sandbox.article
 (
   id         bigserial primary key,
   category   integer references sandbox.category(id),
   title      text not null,
   content    text
 );

create table sandbox.comment
 (
   id         bigserial primary key,
   article    integer references sandbox.article(id),
   content    text
 );

 --SELECT floor(random() * 10 + 1)::int;

insert into sandbox.article(category, title, content)
     select floor(random()*1+3) as category,
            initcap(sandbox.lorem(5)) as title,
            sandbox.lorem(100) as content
       from generate_series(1, 1000) as t(x);

insert into sandbox.comment(article, content)
     select random(1, 1000) as article,
            sandbox.lorem(150) as content
       from generate_series(1, 50000) as t(x);
            
select article.id, category.name, title
  from      sandbox.article
       join sandbox.category
         on category.id = article.category
 limit 3;

select count(*),
       avg(length(title))::int as avg_title_length,
       avg(length(content))::int as avg_content_length
  from sandbox.article;

   select article.id, article.title, count(*)
     from      sandbox.article
          join sandbox.comment
            on article.id = comment.article
group by article.id
order by count desc
   limit 5;

select category.name,
       count(distinct article.id) as articles,
       count(*) as comments
  from      sandbox.category
       left join sandbox.article on article.category = category.id
       left join sandbox.comment on comment.article = article.id
group by category.name
order by category.name;

rollback;
结果如下:

\ir 'C:/Users/Think/Desktop/New folder/TAOP/sql/06-data-modeling/28-repl/01_03_schema_copy.sql'
我已经在谷歌上搜索过了,似乎没有什么结果。所以我真的不知道LOREM是什么意思? 因为我似乎对洛勒姆的事守口如瓶。这本书的名字是PostgreSQL的艺术,一直在跟进,所以遇到了一些问题。 是出版业的一个术语。该名称指页面布局实体模型上的假文本填充空间。文本一目了然似乎是来自拉丁语的单词,如英语。但是这些话实际上都是胡说八道

您的教科书正在使用一个库来生成此类假文本,以填充数据库字段中的空间。这对于设计、测试和演示实时数据不可用的系统非常有用。实际数据可能还不存在。或者真实数据可能是敏感的/私有的,因此不适合/非法在生产系统之外使用

代码库作为扩展添加到Postgres中。你的教科书显然在说这样的延伸。这个特定的扩展目前还没有与常用的Postgres发行版捆绑在一起。因此,您需要获得这样一个扩展并将其安装到您的Postgres集群中



顺便说一句,我碰巧问了,但问的是H2数据库而不是Postgres。由于基于Java,一个完全不同的解决方案是可能的。

在第二页,作者清楚地说明了他的意图。只是他忘了在他的脚本中包含这些“创建随机数据集的特殊函数”。这是相关链接,但似乎无法在Windows中下载。还有其他方法生成随机文本吗?@JianHe有很多方法可以生成假文本或其他随机值。我相信你自己也能想到一些。您可以通过编写SQL脚本、编写存储过程、构建/安装扩展、调用web服务或在应用程序中编写例程来实现。
BEGIN
CREATE SCHEMA
CREATE TABLE
INSERT 0 4
CREATE TABLE
CREATE TABLE
psql:C:/Users/Think/Desktop/New folder/TAOP/sql/06-data-modeling/28-repl/01_03_schema_copy.sql:35: ERROR:  function sandbox.lorem(integer) does not exist
LINE 3:             initcap(sandbox.lorem(5)) as title,
                            ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
psql:C:/Users/Think/Desktop/New folder/TAOP/sql/06-data-modeling/28-repl/01_03_schema_copy.sql:40: ERROR:  current transaction is aborted, commands ignored until end of transaction block
psql:C:/Users/Think/Desktop/New folder/TAOP/sql/06-data-modeling/28-repl/01_03_schema_copy.sql:46: ERROR:  current transaction is aborted, commands ignored until end of transaction block
psql:C:/Users/Think/Desktop/New folder/TAOP/sql/06-data-modeling/28-repl/01_03_schema_copy.sql:51: ERROR:  current transaction is aborted, commands ignored until end of transaction block
psql:C:/Users/Think/Desktop/New folder/TAOP/sql/06-data-modeling/28-repl/01_03_schema_copy.sql:59: ERROR:  current transaction is aborted, commands ignored until end of transaction block
psql:C:/Users/Think/Desktop/New folder/TAOP/sql/06-data-modeling/28-repl/01_03_schema_copy.sql:68: ERROR:  current transaction is aborted, commands ignored until end of transaction block
ROLLBACK