溫馨提示×

MySQL中Geometry數(shù)據(jù)的導入導出方法

小樊
116
2024-08-15 10:20:33
欄目: 云計算

  1. 導入Geometry數(shù)據(jù):
  • 使用LOAD DATA INFILE語句導入數(shù)據(jù),例如:
LOAD DATA INFILE 'path/to/your/file.csv'
INTO TABLE your_table
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n'
(column1, column2, @geo_data)
SET geometry_column = ST_GeomFromText(@geo_data);
  • 使用MySQL Workbench工具導入數(shù)據(jù),可以直接在工具中選擇導入的文件并指定字段映射。
  1. 導出Geometry數(shù)據(jù):
  • 使用SELECT語句查詢數(shù)據(jù)并導出為文本文件,例如:
SELECT column1, column2, ST_AsText(geometry_column) AS geo_data
INTO OUTFILE 'path/to/your/export/file.csv'
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM your_table;
  • 使用MySQL Workbench工具導出數(shù)據(jù),可以執(zhí)行查詢并在結(jié)果集上右鍵點擊選擇導出為CSV文件。

0