먼저 테이블을 생성하겠습니다 -
mysql> create table DemoTable ( Id int ); Query OK, 0 rows affected (0.71 sec)
삽입 명령을 사용하여 테이블에 일부 레코드 삽입 -
mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.31 sec) mysql> insert into DemoTable values(101); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values(102); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(103); Query OK, 1 row affected (0.64 sec) mysql> insert into DemoTable values(104); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(105); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable values(106); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable values(107); Query OK, 1 row affected (0.44 sec) mysql> insert into DemoTable values(108); Query OK, 1 row affected (0.62 sec) mysql> insert into DemoTable values(109); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(110); Query OK, 1 row affected (0.31 sec) mysql> insert into DemoTable values(111); Query OK, 1 row affected (0.94 sec) mysql> insert into DemoTable values(112); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable values(113); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable values(114); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(115); Query OK, 1 row affected (0.25 sec)
select 문을 사용하여 테이블의 모든 레코드 표시 -
mysql> select *from DemoTable;
이것은 다음과 같은 출력을 생성합니다 -
+------+ | Id | +------+ | 100 | | 101 | | 102 | | 103 | | 104 | | 105 | | 106 | | 107 | | 108 | | 109 | | 110 | | 111 | | 112 | | 113 | | 114 | | 115 | +------+ 16 rows in set (0.00 sec)
다음은 처음 10개 행과 나머지 행을 가져오는 쿼리입니다. -
mysql> select *from DemoTable LIMIT 999 offset 0;
이것은 다음과 같은 출력을 생성합니다 -
+------+ | Id | +------+ | 100 | | 101 | | 102 | | 103 | | 104 | | 105 | | 106 | | 107 | | 108 | | 109 | | 110 | | 111 | | 112 | | 113 | | 114 | | 115 | +------+ 16 rows in set (0.00 sec)