Use a PostgreSQL native interface database connection to insert product data from MATLAB® into a new table in a PostgreSQL database. Then, reverse the changes made to the database.
Create a PostgreSQL native interface database connection to a PostgreSQL database using the data source name, user name, and password. The database contains the tables productTable
and suppliers
.
Allow manual committing of changes to the database by setting the AutoCommit
property to off
.
Create a MATLAB table that contains data for two products. The data is stored in the productTable
and suppliers
tables.
Insert the product data into a new table named toytable
.
Import the contents of the database table into MATLAB and display the rows. The results contain two rows for the inserted products.
rows=2×5 table
productnumber stocknumber suppliernumber unitcost productdescription
_____________ ___________ ______________ ________ __________________
30 5e+05 1000 25 "Rubik's Cube"
40 6e+05 2000 30 "Doll House"
Reverse the changes made to the database.
Search for the table. The table no longer exists.
Close the database connection.