Inserting Data
In DatabaseSpy, you have several possibilities to populate your tables with data:
•Import database data from CSV or XML files, see Importing Database Data
•Manually add new rows directly into the Result grid. You can also paste into the Result grid cell ranges copied from another Result grid or from external files such as Microsoft Excel spreadsheets, see Adding and Copying Rows.
When you want to add only a few rows of data, you can also generate INSERT statements and enter the values manually in the SQL Editor. You can enter data for a particular column or for the entire row of a table.
To insert data using INSERT statements:
1.Connect to the database and show the respective data source in the Online Browser.
2.Right-click the table and select Show in new SQL Editor | Insert from the context menu. Alternatively, hold down the right mouse button, drag the table into an open SQL Editor window and select Insert from the context menu. An INSERT INTO... statement is generated in the SQL Editor.
Note: | Auto-increment and computed columns do not appear in the generated INSERT statement. |
3.Enter the desired values in the VALUES part of the statement (the number of commas depends on the number of columns in the respective table). If required, check the data type of the individual columns in the Properties window of the Online Browser.
4.Click the Execute button to execute the statement and to insert the data into the database.
5.Optionally, save the SQL statement if you need to insert the same kind of data frequently, see Opening, Saving, and Closing SQL Files.
To insert data only into specific columns of a table:
1.Connect to the database and show the respective data source in the Online Browser.
2.In the Online Browser, expand the table you want to edit to and select the column(s) into which you want to insert data. If your table contains columns that are not nullable, make sure to include these columns in the selection.
3.Right-click and select Show in new SQL Editor | Insert from the context menu. Alternatively, hold down the right mouse button, drag the column(s) into an open SQL Editor window and select Insert from the context menu. An INSERT INTO... statement is generated in the SQL Editor.
Note: | Auto-increment and computed columns do not appear in the generated INSERT statement. |
4.Enter the desired value(s) in the VALUES part of the statement. You may also have to enter the primary key for the new table row. Add the name and the value of the primary key to the statement in this case.
5.Click the Execute button to execute the statement and to insert the data into the database.
6.Optionally, save the SQL statement if you need to insert the same kind of data frequently, see Opening, Saving, and Closing SQL Files.