How would one implement or use an SQL database in a contract? What would be the best practices for this? There could be a lot of data here, but I need to easily select and update.

3 Answers 3


EOS is first and foremost blockchain system that supports Database to share data among users. However there are some notes that may change your mind of thinking how that database looks like.

  • This is in-memory database which means to be accessed by dapp. Note that EOS blocktime is 0.5 second so that executed time would be fast.
  • It's permanently stored in blockchain, shared among nodes and be loaded in to RAM.
  • It's implemented by serializable-like function so you can manipulate it the same way as objects.
  • Ram is allocated to each user so Smart contract needs optimize how data is stored.

Contracts can't call out to SQL servers or any other server. They can use table storage through multi_index, but it's direct access with no SQL interpreter.


The OCI video shows exactly how to do select and update queries using the eosio::multi_index:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.