You don't have to export and import the tables from the database; you don't have to build an export/import function for your theme either. There is an Export tool built in WordPress under the Tools menu and in the same sub-menu you'll find the Import tool as well. The process is pretty straightforward:
- export the posts;
- make a new WP installation in the a directory;
- copy/install and activate the plugins if you used any on the development installation;
- copy your theme and activate it (this is important if you have some custom post types or custom fields associated with it or with the plugins);
- go to the Import screen and install the WordPress tool, it's the last in the list of tools;
- activate the tool and then upload the exported file.
Sidenote, exporting and importing data is not a functionality that's associated with the WordPress themes. :)
Also, the process of manual export and import of tables is tricky as there are many connections between the tables, unique ID and many more thing that can go wrong.
If you want to read more on the Export and the Import take a look in the Codex: the export screen; the import screen and some bonus read for the import.