【为什么?阿里规定超过 3 张表禁止 join】看完本篇文章,另外我还附加附件,所谓搂草打兔子 。就是快速造数据 。你可以自己先写脚本造数据,看看我是怎么造数据的,就知道我的技巧了 。
八,附上部分截图
文章插图
文章插图
文章插图
文章插图
九,附上sql语句和造数据脚本
use stu;drop table if exists student;create table student( s_id int(11) not auto_increment ,sno int(11),sname varchar(50),sage int(11),ssex varchar(8) ,father_id int(11),mather_id int(11),note varchar(500),primary key (s_id),unique key uk_sno (sno)) engine=innodb default charset=utf8mb4;truncate table student;delimiter $$drop function if exists insert_student_data $$create function insert_student_datareturns int deterministicbegindeclare i int;set i=1;while i<50000000 doinsert into student values(i ,i, concat('name',i),i,case when floor(rand*10)%2=0 then 'f' else 'm' end,floor(rand*100000),floor(rand*1000000),concat('note',i) );set i=i+1;end while;return 1;end$$delimiter ;select insert_student_data;select count(*) from student;use stu;create table course(c_id int(11) not auto_increment ,cname varchar(50)note varchar(500), primary key (c_id)) engine=innodb default charset=utf8mb4;truncate table course;delimiter $$drop function if exists insert_course_data $$create function insert_course_datareturns int deterministicbegindeclare i int;set i=1;while i<=1000 doinsert into course values(i , concat('course',i),floor(rand*1000),concat('note',i) );set i=i+1;end while;return 1;end$$delimiter ;select insert_course_data;select count(*) from course;use stu;drop table if exists sc;create table sc(s_id int(11),c_id int(11),t_id int(11),score int(11)) engine=innodb default charset=utf8mb4;truncate table sc;delimiter $$drop function if exists insert_sc_data $$create function insert_sc_datareturns int deterministicbegindeclare i int;set i=1;while i<=50000000 doinsert into sc values( i,floor(rand*1000),floor(rand*10000000),floor(rand*750)) ;set i=i+1;end while;return 1;end$$delimiter ;select insert_sc_data;commit;select insert_sc_data;commit;create index idx_s_id on sc(s_id) ;create index idx_t_id on sc(t_id) ;create index idx_c_id on sc(c_id) ;select count(*) from sc;use stu;drop table if exists teacher;create table teacher(t_id int(11) not auto_increment ,tname varchar(50) ,note varchar(500),primary key (t_id)) engine=innodb default charset=utf8mb4;truncate table teacher;delimiter $$drop function if exists insert_teacher_data $$create function insert_teacher_datareturns int deterministicbegindeclare i int;set i=1;while i<=10000000 doinsert into teacher values(i , concat('tname',i),concat('note',i) );set i=i+1;end while;return 1;end$$delimiter ;select insert_teacher_data;commit;select count(*) from teacher;
这个是oracle的测试和造数据脚本create tablespace scott_data datafile '/home/oracle/oracle_space/sitpay1/scott_data.dbf' size 1024m autoextend on; create tablespace scott_index datafile '/home/oracle/oracle_space/sitpay1/scott_index.dbf' size 64m autoextend on;create temporary tablespace scott_temp tempfile '/home/oracle/oracle_space/sitpay1/scott_temp.dbf' size 64m autoextend on;drop user scott cascade;create user scott identified by tiger default tablespace scott_data temporary tablespace scott_temp ;grant resource,connect,dba to scott;drop table student;create table student( s_id number(11) ,sno number(11) ,sname varchar2(50),sage number(11),ssex varchar2(8) ,father_id number(11),mather_id number(11),note varchar2(500)) nologging;truncate table student;create or replace procedure insert_student_dataisq number(11);beginq:=0;for i in 1..50 loopinsert /*+Append*/ into student select rownum+q as s_id,rownum+q as sno, concat('sutdent',rownum+q ) as sname,floor(dbms_random.value(1,100)) as sage,'f' as ssex,rownum+q as father_id,rownum+q as mather_id,concat('note',rownum+q ) as note from dual connect by level<=1000000;q:=q+1000000;commit;end loop;end insert_student_data;/call insert_student_data;alter table student add constraint pk_student primary key (s_id);commit;select count(*) from student;create table course(c_id number(11) primary key,cname varchar2(50),note varchar2(500)) ;truncate table course;create or replace procedure insert_course_dataisq number(11);beginfor i in 1..1000 loopinsert /*+append*/ into course values(i , concat('name',i),concat('note',i) );end loop;end insert_course_data;/call insert_course_data;commit;select count(*) from course;create table sc(s_id number(11),c_id number(11),t_id number(11),score number(11)) nologging;truncate table sc;create or replace procedure insert_sc_dataisq number(11);beginq:=0;for i in 1..50 loopinsert /*+append*/ into sc select rownum+q as s_id, floor(dbms_random.value(0,1000)) as c_id,floor(dbms_random.value(0,10000000)) t_id,floor(dbms_random.value(0,750)) as score from dual connect by level<=1000000;q:=q+1000000;commit;end loop;end insert_sc_data;/call insert_sc_data;create index idx_s_id on sc(s_id) ;create index idx_t_id on sc(t_id) ;create index idx_c_id on sc(c_id) ;select count(*) from sc;create table teacher(t_id number(11) ,tname varchar2(50) ,note varchar2(500))nologging ;truncate table teacher;create or replace procedure insert_teacher_dataisq number(11);beginq:=0;for i in 1..10 loopinsert /*+append*/ into teacher select rownum+q as t_id, concat('teacher',rownum+q ) as tname,concat('note',rownum+q ) as note from dual connect by level<=1000000;q:=q+1000000;commit;end loop;end insert_teacher_data;/call insert_teacher_data;alter table teacher a
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 企业选择路由器为什么要看VPN?
- 百度蜘蛛抓取量为什么越来越少?
- 炸糍粑为什么会起泡,糍粑怎样炸来又软又泡又黄
- 如果我住在金字塔里肯定杀了法老 为什么法老死后要埋在金字塔里
- 婚戒为什么首选圆钻?它与异形钻相比有什么优势?不选圆钻可以吗
- 互联网拒绝35岁!阿里、腾讯劝退高龄员工,哪些职业越老越吃香?
- 为什么借钱要春节前还2022,欠人钱过年为什么不好
- 董卿为什么被央视解雇原因董卿是哪一年出生的 董卿为什么被央视解雇原因知乎
- 翡翠|翡翠为什么会出现年年涨价的情况?
- 求职|为什么「金三银四」在 2022 消失了呢?