2010-06-07 38 views

回答

1

首先,更改架构以添加你想要的列。我假设你知道如何做到这一点。

其次,运行拆分数据的“更新”查询。

update mytable set column1 = ...,column2 = ...,column3 = ...;

诀窍是制定“...”从“源”列中提取右列。 (),rtrim()和CASE(请参阅http://www.sqlite.org/lang_expr.html),但是如果您定义了一个用户定义的函数,可能会更容易一些,可能是基于length()和substring() )。

+0

而且,当然,另一种方法是选择所有值,在它们上运行sed表达式以创建更新语句,然后将输出文件作为SQL命令运行。 select table from table> file sed -e“s/^([^:] *):([^:] *):([^:] *)\ $/update table set column1 ='\ \ 1',column2 ='\\ 2',column3 ='\\ 3'其中source ='\ $';“ < file > newfile sqlite3 2010-06-07 01:29:02

0

如果你正在使用PHP,这是不言而喻somehitng这样的:

PHP:

$explodedStr = explode(":", $delimitedStr); 

SQL:

"INSERT INTO tableName (column1, column2, column3) 
VALUES ('".$explodedStr[0]."','".$explodedStr[1]."', '".$explodedStr[2]." 
+0

你实际上可能需要更新,而不是插入。 – 2010-06-07 01:29:02

相关问题