테이블 superstatistics_counter
에 100 000 개의 행을 생성 할 SQL 쿼리가 있습니다. 인터넷에서이 사실을 발견했습니다. 그러나 그것은 저에게 마법입니다. 나는 SQL 쿼리에 대해 기본적인 이해를하지 못했다. 나는 봤지만 아직 내게 불분명하다 ...내가 이해하지 못하는 SQL 쿼리
괄호 안의 진술은 무엇을 의미합니까? t
, t2
은 무엇을 의미합니까? @열?
INSERT INTO superstatistics_counter(nid, totalcount, daycount,timestamp) SELECT @row := @row + 1 as row, 100, 50, NOW() FROM
(select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t,
(select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t2,
(select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t3,
(select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t4,
(select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t5,
(SELECT @row:=0) t6
감사합니다.
암시 적'JOIN' 구문 ('FROM' 절의',')을 통해'CROSS JOIN'을하고 있습니다. 기본적으로 모든 하위 선택 문의 cartesan 제품을 가져와 0에서 99,999까지의 모든 숫자를 산출합니다. 't # '는 각 하위 선택의 별명입니다. – Siyual
t는 트랜잭션 번호로 간단히 참조합니다 –
t, t2 등은 괄호 안에있는 이름의 별칭입니다. @는 MySql의 변수 이름을 짓는 데 사용됩니다. – MarioZ