Main Content

Customize Import Options Using Database Explorer App

You can customize import options using the Database Explorer app after creating an SQL query and before importing data into the MATLAB® Workspace. For details about creating SQL queries, see Create SQL Queries Using Database Explorer App.

Follow these steps as a general workflow to customize import options by using the Set Import Options dialog box. This workflow assumes that you create an SQL query that selects all data from a database table containing employee information.

  • In the Options section, click Import Options. The Set Import Options dialog box opens and displays the default general options.

    Set Import Options dialog box with General Options selected

  • Under Variable Name, enter a different name for a specific variable to change its name in the imported data.

  • Under Variable Type, select a different variable type for a specific variable to change its type in the imported data. The selected variable type must be compatible with the database type. For valid data types, see the Option1,OptionValue1,...,OptionN,OptionValueN input argument of the setoptions function.

  • Under Missing Value, enter a different value for a specific variable to change how missing data is represented in the imported data. The data type of the specified value must match the variable type.

  • From the Option Type list, select Text Options. The Set Import Options dialog box displays the import options for variables with text data types.

    Set Import Options dialog box with Text Options selected

    For details about customizing text import options, see the Option1,OptionValue1,...,OptionN,OptionValueN input argument of the setoptions function.

  • After you select the datetime variable type for any variable in the general options, you can customize the datetime import options. For example, assume that you set the HIRE_DATE variable to the datetime variable type. From the Option Type list, select Datetime Options. The Set Import Options dialog box displays the import options for variables with datetime data types.

    Set Import Options dialog box with Datetime Options selected

    For details about customizing datetime import options, see the Option1,OptionValue1,...,OptionN,OptionValueN input argument of the setoptions function.

  • After you select the categorical variable type for any variable in the general options, you can customize the categorical import options. For example, assume that you set the JOB_ID variable to the categorical variable type. From the Option Type list, select Categorical Options. The Set Import Options dialog box displays the import options for variables with categorical data types.

    Set Import Options dialog box with Categorical Options selected

    For details about customizing categorical import options, see the Option1,OptionValue1,...,OptionN,OptionValueN input argument of the setoptions function.

  • Click OK. The dialog box closes and the Data Preview pane shows a preview of the data using the import options.

  • In the Import section, click Import data to import all SQL query results as a table in the MATLAB Workspace, according to the specified import options.

  • In the Import section, select Import Data > Generate MATLAB Script to display a MATLAB script in the MATLAB Editor. The script mimics the actions of customizing import options in the Set Import Options dialog box for each option you set by using the setoptions function. For details about generating MATLAB scripts, see Generate SQL Query and MATLAB Script.

See Also

Apps

Related Topics