www.gusucode.com > database 案例源码程序 matlab代码 > database/InsertTableRecordMATLABInterfaceToSQLiteExample.m
%% Insert a Table Record Using the MATLAB(R) Interface to SQLite % Create a SQLite connection |conn| to a new SQLite database file % |tutorial.db|. Specify the file name in the current working folder. %% dbfile = fullfile(pwd,'tutorial.db'); conn = sqlite(dbfile,'create'); %% % Create the table |inventoryTable| using |exec|. %% createInventoryTable = ['create table inventoryTable ' ... '(productNumber NUMERIC, Quantity NUMERIC, ' ... 'Price NUMERIC, inventoryDate VARCHAR)']; exec(conn,createInventoryTable) %% % |inventoryTable| is an empty table in |tutorial.db|. %% % Insert a row of data into |inventoryTable|. %% colnames = {'productNumber','Quantity','Price','inventoryDate'}; insert(conn,'inventoryTable',colnames, ... {20,150,50.00,'11/3/2015 2:24:33 AM'}) %% % Close the SQLite connection. close(conn)