I want to create an mnesia schema and table in my code after the system starts, so I need to detect weather the mnesia schema and table have been created. If not, I want to create them. Is this a good idea? And how can I detect the mnesia schema and table?
Mnesia is a distributed, soft real-time database management system written in the Erlang programming language. It is distributed as part of the Open Telecom Platform. Mnesia.
Mnesia is a complete database management system (DBMS) included in Erlang OTP, an open source development environment for concurrent programming based on the Erlang language.
One way to handle this is -
Try creating table using mnesia:create_table(Table_name, ...)
If the table already exists (1) would return {aborted,
{already_exists, Table_name}}
If table doesn't exit, it will be created and {atomic,ok}
will be
returned if successful
If there is any error in table creation in (3), {aborted, Reason}
will be returned.
Handle each of these return values as required.
check out mnesia:system_info/1
, mnesia:schema/0
, mnesia:schema/1
and mnesia:table_info/2
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With