clear markdown compare help donate or buy diddy dollings comments/suggestions/bugs a leap of faith? bible365
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 582720 fiddles created (13319 in the last week).

CREATE TABLE actor ( actor_id serial, -- PRIMARY KEY -- see below first_name character varying(45) NOT NULL, last_name character varying(45) NOT NULL, last_update timestamptz DEFAULT now() NOT NULL ); CREATE TABLE film ( film_id serial, -- PRIMARY KEY -- see below title character varying(255) NOT NULL, last_update timestamptz DEFAULT now() NOT NULL ); CREATE TABLE film_actor ( actor_id int NOT NULL, film_id int NOT NULL, last_update timestamp without time zone DEFAULT now() NOT NULL -- PRIMARY KEY (film_id, actor_id) -- see below );
 hidden batch(es)


ALTER TABLE actor ADD CONSTRAINT actor_pkey PRIMARY KEY (actor_id); ALTER TABLE film ADD CONSTRAINT film_pkey PRIMARY KEY (film_id); ALTER TABLE film_actor ADD CONSTRAINT film_actor_pkey PRIMARY KEY (film_id, actor_id) , ADD CONSTRAINT film_actor_actor_id_fkey FOREIGN KEY (actor_id) REFERENCES actor(actor_id) , ADD CONSTRAINT film_actor_film_id_fkey FOREIGN KEY (film_id) REFERENCES film(film_id);
 hidden batch(es)


create or replace function random_string(length integer) returns text as $$ declare chars text[] := '{0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}'; result text := ''; i integer := 0; begin if length < 0 then raise exception 'Given length cannot be less than 0'; end if; for i in 1..length loop result := result || chars[1+random()*(array_length(chars, 1)-1)]; end loop; return result; end; $$ language plpgsql; insert into film(title) select random_string(30) from generate_series(1,100); insert into actor(first_name, last_name) select random_string(30), random_string(30) from generate_series(1,(select count(*)*5 from film)); insert into film_actor(film_id, actor_id) select film_id, actor_id from film cross join lateral (select actor_id from actor where film_id is not null order by random() limit 2) as actor;
100 rows affected
500 rows affected
200 rows affected
 hidden batch(es)


select * from film_actor;
actor_id film_id last_update
88 1 2019-02-25 19:44:25.720794
254 1 2019-02-25 19:44:25.720794
86 2 2019-02-25 19:44:25.720794
397 2 2019-02-25 19:44:25.720794
482 3 2019-02-25 19:44:25.720794
96 3 2019-02-25 19:44:25.720794
207 4 2019-02-25 19:44:25.720794
144 4 2019-02-25 19:44:25.720794
167 5 2019-02-25 19:44:25.720794
66 5 2019-02-25 19:44:25.720794
293 6 2019-02-25 19:44:25.720794
174 6 2019-02-25 19:44:25.720794
227 7 2019-02-25 19:44:25.720794
115 7 2019-02-25 19:44:25.720794
161 8 2019-02-25 19:44:25.720794
205 8 2019-02-25 19:44:25.720794
171 9 2019-02-25 19:44:25.720794
213 9 2019-02-25 19:44:25.720794
114 10 2019-02-25 19:44:25.720794
130 10 2019-02-25 19:44:25.720794
7 11 2019-02-25 19:44:25.720794
27 11 2019-02-25 19:44:25.720794
321 12 2019-02-25 19:44:25.720794
464 12 2019-02-25 19:44:25.720794
131 13 2019-02-25 19:44:25.720794
116 13 2019-02-25 19:44:25.720794
77 14 2019-02-25 19:44:25.720794
156 14 2019-02-25 19:44:25.720794
320 15 2019-02-25 19:44:25.720794
237 15 2019-02-25 19:44:25.720794
227 16 2019-02-25 19:44:25.720794
239 16 2019-02-25 19:44:25.720794
476 17 2019-02-25 19:44:25.720794
144 17 2019-02-25 19:44:25.720794
298 18 2019-02-25 19:44:25.720794
311 18 2019-02-25 19:44:25.720794
297 19 2019-02-25 19:44:25.720794
335 19 2019-02-25 19:44:25.720794
249 20 2019-02-25 19:44:25.720794
99 20 2019-02-25 19:44:25.720794
442 21 2019-02-25 19:44:25.720794
65 21 2019-02-25 19:44:25.720794
454 22 2019-02-25 19:44:25.720794
28 22 2019-02-25 19:44:25.720794
152 23 2019-02-25 19:44:25.720794
295 23 2019-02-25 19:44:25.720794
221 24 2019-02-25 19:44:25.720794
55 24 2019-02-25 19:44:25.720794
318 25 2019-02-25 19:44:25.720794
479 25 2019-02-25 19:44:25.720794
147 26 2019-02-25 19:44:25.720794
484 26 2019-02-25 19:44:25.720794
224 27 2019-02-25 19:44:25.720794
3 27 2019-02-25 19:44:25.720794
500 28 2019-02-25 19:44:25.720794
390 28 2019-02-25 19:44:25.720794
241 29 2019-02-25 19:44:25.720794
388 29 2019-02-25 19:44:25.720794
100 30 2019-02-25 19:44:25.720794
126 30 2019-02-25 19:44:25.720794
24 31 2019-02-25 19:44:25.720794
127 31 2019-02-25 19:44:25.720794
387 32 2019-02-25 19:44:25.720794
262 32 2019-02-25 19:44:25.720794
54 33 2019-02-25 19:44:25.720794
357 33 2019-02-25 19:44:25.720794
466 34 2019-02-25 19:44:25.720794
152 34 2019-02-25 19:44:25.720794
288 35 2019-02-25 19:44:25.720794
369 35 2019-02-25 19:44:25.720794
166 36 2019-02-25 19:44:25.720794
494 36 2019-02-25 19:44:25.720794
347 37 2019-02-25 19:44:25.720794
307 37 2019-02-25 19:44:25.720794
256 38 2019-02-25 19:44:25.720794
130 38 2019-02-25 19:44:25.720794
197 39 2019-02-25 19:44:25.720794
49 39 2019-02-25 19:44:25.720794
492 40 2019-02-25 19:44:25.720794
293 40 2019-02-25 19:44:25.720794
262 41 2019-02-25 19:44:25.720794
38 41 2019-02-25 19:44:25.720794
144 42 2019-02-25 19:44:25.720794
128 42 2019-02-25 19:44:25.720794
173 43 2019-02-25 19:44:25.720794
102 43 2019-02-25 19:44:25.720794
422 44 2019-02-25 19:44:25.720794
481 44 2019-02-25 19:44:25.720794
270 45 2019-02-25 19:44:25.720794
435 45 2019-02-25 19:44:25.720794
171 46 2019-02-25 19:44:25.720794
16 46 2019-02-25 19:44:25.720794
486 47 2019-02-25 19:44:25.720794
300 47 2019-02-25 19:44:25.720794
441 48 2019-02-25 19:44:25.720794
451 48 2019-02-25 19:44:25.720794
425 49 2019-02-25 19:44:25.720794
339 49 2019-02-25 19:44:25.720794
288 50 2019-02-25 19:44:25.720794
404 50 2019-02-25 19:44:25.720794
287 51 2019-02-25 19:44:25.720794
356 51 2019-02-25 19:44:25.720794
170 52 2019-02-25 19:44:25.720794
161 52 2019-02-25 19:44:25.720794
429 53 2019-02-25 19:44:25.720794
226 53 2019-02-25 19:44:25.720794
201 54 2019-02-25 19:44:25.720794
389 54 2019-02-25 19:44:25.720794
231 55 2019-02-25 19:44:25.720794
446 55 2019-02-25 19:44:25.720794
279 56 2019-02-25 19:44:25.720794
367 56 2019-02-25 19:44:25.720794
427 57 2019-02-25 19:44:25.720794
391 57 2019-02-25 19:44:25.720794
161 58 2019-02-25 19:44:25.720794
52 58 2019-02-25 19:44:25.720794
204 59 2019-02-25 19:44:25.720794
211 59 2019-02-25 19:44:25.720794
338 60 2019-02-25 19:44:25.720794
258 60 2019-02-25 19:44:25.720794
89 61 2019-02-25 19:44:25.720794
489 61 2019-02-25 19:44:25.720794
14 62 2019-02-25 19:44:25.720794
206 62 2019-02-25 19:44:25.720794
95 63 2019-02-25 19:44:25.720794
266 63 2019-02-25 19:44:25.720794
208 64 2019-02-25 19:44:25.720794
405 64 2019-02-25 19:44:25.720794
405 65 2019-02-25 19:44:25.720794
287 65 2019-02-25 19:44:25.720794
310 66 2019-02-25 19:44:25.720794
145 66 2019-02-25 19:44:25.720794
212 67 2019-02-25 19:44:25.720794
137 67 2019-02-25 19:44:25.720794
65 68 2019-02-25 19:44:25.720794
46 68 2019-02-25 19:44:25.720794
477 69 2019-02-25 19:44:25.720794
500 69 2019-02-25 19:44:25.720794
239 70 2019-02-25 19:44:25.720794
86 70 2019-02-25 19:44:25.720794
311 71 2019-02-25 19:44:25.720794
65 71 2019-02-25 19:44:25.720794
255 72 2019-02-25 19:44:25.720794
223 72 2019-02-25 19:44:25.720794
125 73 2019-02-25 19:44:25.720794
181 73 2019-02-25 19:44:25.720794
410 74 2019-02-25 19:44:25.720794
49 74 2019-02-25 19:44:25.720794
172 75 2019-02-25 19:44:25.720794
415 75 2019-02-25 19:44:25.720794
477 76 2019-02-25 19:44:25.720794
125 76 2019-02-25 19:44:25.720794
174 77 2019-02-25 19:44:25.720794
196 77 2019-02-25 19:44:25.720794
410 78 2019-02-25 19:44:25.720794
4 78 2019-02-25 19:44:25.720794
81 79 2019-02-25 19:44:25.720794
353 79 2019-02-25 19:44:25.720794
364 80 2019-02-25 19:44:25.720794
424 80 2019-02-25 19:44:25.720794
407 81 2019-02-25 19:44:25.720794
327 81 2019-02-25 19:44:25.720794
149 82 2019-02-25 19:44:25.720794
294 82 2019-02-25 19:44:25.720794
255 83 2019-02-25 19:44:25.720794
385 83 2019-02-25 19:44:25.720794
123 84 2019-02-25 19:44:25.720794
260 84 2019-02-25 19:44:25.720794
368 85 2019-02-25 19:44:25.720794
148 85 2019-02-25 19:44:25.720794
357 86 2019-02-25 19:44:25.720794
103 86 2019-02-25 19:44:25.720794
446 87 2019-02-25 19:44:25.720794
275 87 2019-02-25 19:44:25.720794
486 88 2019-02-25 19:44:25.720794
482 88 2019-02-25 19:44:25.720794
399 89 2019-02-25 19:44:25.720794
178 89 2019-02-25 19:44:25.720794
302 90 2019-02-25 19:44:25.720794
3 90 2019-02-25 19:44:25.720794
100 91 2019-02-25 19:44:25.720794
163 91 2019-02-25 19:44:25.720794
321 92 2019-02-25 19:44:25.720794
370 92 2019-02-25 19:44:25.720794
43 93 2019-02-25 19:44:25.720794
250 93 2019-02-25 19:44:25.720794
145 94 2019-02-25 19:44:25.720794
438 94 2019-02-25 19:44:25.720794
179 95 2019-02-25 19:44:25.720794
245 95 2019-02-25 19:44:25.720794
356 96 2019-02-25 19:44:25.720794
370 96 2019-02-25 19:44:25.720794
309 97 2019-02-25 19:44:25.720794
146 97 2019-02-25 19:44:25.720794
273 98 2019-02-25 19:44:25.720794
87 98 2019-02-25 19:44:25.720794
323 99 2019-02-25 19:44:25.720794
41 99 2019-02-25 19:44:25.720794
175 100 2019-02-25 19:44:25.720794
497 100 2019-02-25 19:44:25.720794
 hidden batch(es)