기본값을 설정하려면 MySQL에서 DEFAULT 키워드를 사용할 수 있습니다. 먼저 테이블을 생성하겠습니다 -
mysql> create table DemoTable -> ( -> EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> EmployeeName varchar(20), -> EmployeeJoiningDate datetime default '0000-00-00 00:00:00' -> )ENGINE=MyISAM,AUTO_INCREMENT=100; Query OK, 0 rows affected (0.21 sec)
삽입 명령을 사용하여 테이블에 일부 레코드 삽입 -
mysql> insert into DemoTable(EmployeeName) values('Chris'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(EmployeeName) values('David'); Query OK, 1 row affected (0.04 sec) mysql> insert into DemoTable(EmployeeName) values('Mike'); Query OK, 1 row affected (0.03 sec) mysql> insert into DemoTable(EmployeeName) values('Sam'); Query OK, 1 row affected (0.06 sec)
select 문을 사용하여 테이블의 모든 레코드 표시 -
mysql> select *from DemoTable;
이것은 다음과 같은 출력을 생성합니다 -
+------------+--------------+---------------------+ | EmployeeId | EmployeeName | EmployeeJoiningDate | +------------+--------------+---------------------+ | 100 | Chris | 0000-00-00 00:00:00 | | 101 | David | 0000-00-00 00:00:00 | | 102 | Mike | 0000-00-00 00:00:00 | | 103 | Sam | 0000-00-00 00:00:00 | +------------+--------------+---------------------+ 4 rows in set (0.00 sec)