使用MySQL的CLI命令從表中,如導出行: -MySQL的XML導出在數據NULL不重新導入由於錯誤
mysql -h mysql --user=root --password=root --database dms_home --xml -e "SELECT * FROM users WHERE account=4149;" >/var/www/scripts/output/1187515/1187515_users.sql
此輸出文件: -
<resultset statement="SELECT * FROM accounts WHERE accnum=1187515" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<row>
<field name="id">4149</field>
<field name="accnum">1187515</field>
<field name="applicationdate">0000-00-00</field>
<field name="introducer"></field>
<field name="jointacc">0</field>
<field name="consultancy">0</field>
<field name="storage">0</field>
<field name="digitalonly">0</field>
<field name="membership" xsi:nil="true" />
<field name="promocode"></field>
<field name="holdername" xsi:nil="true" />
<field name="testaccount">0</field>
</row>
</resultset>
現在你可以看到有XML行「會員」和「holdername」在2個空,如果我再轉到另一個MySQL服務器/數據庫和重新導入此文件,室內用的顯示警告切換我回到這裏: -
mysql -h mysql -u root -p dms_licence --show-warnings -e "load xml local infile '/var/www/scripts/output/1187515/1187515_account.sql' into table dms_licence.accounts";
Warning (Code 1263): Column set to default value; NULL supplied to NOT NULL column 'id' at row 1
Warning (Code 1263): Column set to default value; NULL supplied to NOT NULL column 'accnum' at row 1
Warning (Code 1263): Column set to default value; NULL supplied to NOT NULL column 'applicationdate' at row 1
Warning (Code 1263): Column set to default value; NULL supplied to NOT NULL column 'introducer' at row 1
Warning (Code 1263): Column set to default value; NULL supplied to NOT NULL column 'jointacc' at row 1
Warning (Code 1263): Column set to default value; NULL supplied to NOT NULL column 'consultancy' at row 1
Warning (Code 1263): Column set to default value; NULL supplied to NOT NULL column 'storage' at row 1
Warning (Code 1263): Column set to default value; NULL supplied to NOT NULL column 'digitalonly' at row 1
Warning (Code 1263): Column set to default value; NULL supplied to NOT NULL column 'promocode' at row 1
Warning (Code 1263): Column set to default value; NULL supplied to NOT NULL column 'testaccount' at row 1
表模式是相同的,插入數據不會導致主鍵或唯一鍵的任何問題。那爲什麼它只插入一個空白記錄?