SETsql_mode='allow_invalid_dates';QueryOK,0rowsaffected,1warning(0.03sec)mysql>Createtabletest_date(date_orderdate);QueryOK,0rowsaffected(0.45sec)"/> SETsql_mode='allow_invalid_dates';QueryOK,0rowsaffected,1warning(0.03sec)mysql>Createtabletest_date(date_orderdate);QueryOK,0rowsaffected(0.45sec)">

 >  기사  >  데이터 베이스  >  MySQL에서 "0000-00-00"을 날짜로 저장하는 방법은 무엇입니까?

MySQL에서 "0000-00-00"을 날짜로 저장하는 방법은 무엇입니까?

王林
王林앞으로
2023-09-07 13:25:02973검색

如何在 MySQL 中将“0000-00-00”存储为日期?

MySQL 테이블의 열에 "0000-00-00"과 같은 날짜를 저장하려면 SQL 모드를 "allow_invalid_date"로 설정해야 합니다. 아래 예에서 이를 보여줍니다. -

mysql> SET sql_mode = 'allow_invalid_dates';
Query OK, 0 rows affected, 1 warning (0.03 sec)

mysql> Create table test_date(date_order date);
Query OK, 0 rows affected (0.45 sec)

mysql> Insert into test_date(date_order) values('0000-00-00');
Query OK, 1 row affected (0.04 sec)

mysql> Select * from test_date;
+------------+
| date_order |
+------------+
| 0000-00-00 |
+------------+
1 row in set (0.00 sec)

위 내용은 MySQL에서 "0000-00-00"을 날짜로 저장하는 방법은 무엇입니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
이 기사는 tutorialspoint.com에서 복제됩니다. 침해가 있는 경우 admin@php.cn으로 문의하시기 바랍니다. 삭제