我有一个小 txt(~130 kb) 我正在尝试导入但给我错误:“创建表时出错:表必须至少有 1 列”
if(mysql_num_rows(mysql_query("SHOW TABLES LIKE 'test'")) == 1){
$sql = "LOAD DATA INFILE 'file.txt' INTO TABLE test IGNORE 1 LINES";
if (mysqli_query($con,$sql)){
echo "Import successfull.";
}
else{
echo "Error importing: " . mysqli_error($con);
}
}
else{
$sql = "CREATE TABLE test";
if (mysqli_query($con,$sql)){
echo "Table created successfully";
}
else{
echo "Error creating table: " . mysqli_error($con);
}
}
txt 的第一行是列名。我可以根据该名称创建列吗?还是我必须手动创建它们?谢谢!