简体   繁体   English

LOREM 是什么意思?

[英]What does LOREM mean?

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;

i execute the following code in PSQL:我在 PSQL 中执行以下代码:

\ir 'C:/Users/Think/Desktop/New folder/TAOP/sql/06-data-modeling/28-repl/01_03_schema_copy.sql'

The following is the result:结果如下:

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

I already googled, seems don't have much result.我已经用谷歌搜索了,似乎没有太多结果。 So I really don't know what's LOREM mean?所以我真的不知道 LOREM 是什么意思? because seems I stuck in line about LOREM.因为似乎我坚持关于 LOREM。 This book name is The Art of PostgreSQL, been following through, so encounter some problem.本书名为The Art of PostgreSQL,一直在跟进,所以遇到了一些问题。 lorem1 lorem2 lorem1 lorem2

Lorem ipsum is a term from the publishing industry. Lorem ipsum是出版业的一个术语。 The name refers to fake text filling space on page layout mock-ups.该名称指的是页面布局模型上的虚假文本填充空间。 The text at a glance appears to be words from a Latin-based language such as English.乍一看,文本似乎是来自拉丁语的单词,例如英语。 But the words are actually all nonsense, gibberish.但话里其实都是胡说八道,胡言乱语。

Your textbook is using a library to generate such fake text to fill up space in the database fields.你的教科书正在使用一个库来生成这样的假文本来填充数据库字段中的空间。 This is useful for designing, testing, and demoing systems where live real data is not available.这对于设计、测试和演示无法获得实时真实数据的系统很有用。 Real data may not yet exist.实际数据可能还不存在。 Or real data may be sensitive/private and therefore inappropriate/illegal to use outside a production system.或者真实数据可能是敏感的/私有的,因此在生产系统之外使用是不合适的/非法的。

Libraries of code are added to Postgres as extensions .代码库作为扩展添加到 Postgres。 Your textbook is apparently calling one such extension.您的教科书显然正在调用这样的扩展名。 That particular extension is not currently bundled with commonly-used distributions of Postgres.该特定扩展目前未与 Postgres 的常用发行版捆绑在一起。 So you will need to obtain such an extension and install it into your Postgres cluster.因此,您需要获取这样的扩展并将其安装到您的 Postgres 集群中。


By the way, I happened to ask a similar Question , but for the H2 database rather than Postgres.顺便说一句,我碰巧问了一个类似的问题,但是是针对 H2 数据库而不是 Postgres。 Being Java-based, an entirely different solution was possible.作为基于 Java 的,完全不同的解决方案是可能的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM