In addition, the computer_id column is a primary key constraint, as shown in the above statement. computer_id is an integer column with auto_increment property, so MariaDB will automatically increment a sequential number when we insert a new row into the specified table.The computer1 table has a different attribute as follows.In the above example, we created the same table as the previous computer table in this table, we just add a JSON function with a check constraint, as shown in the above example.For that reason, we can use check constraint at the time of table creation as follows.Ĭode: create table computer1(comuter_id int not null primary key auto_increment, The good thing in MariaDB is that we have a check constraint to check if an inserted value is valid or not valid after every insert or update operation in MariaDB. See here we have an attr attribute that can store any kind of data, even non-valid JSON.Notice here we don’t use JSON as a data type because that is not available in MariaDB, but we can use it as a function, and it acts as a text string with JSON format. In the above table, we have a different attribute that looks like column names in relational database tables, and we have a column name as attr that can store any relevant information about the computer as a JSON string.Given below are the examples of MariaDB JSON: Example #1 – Structured Data.Ĭode: create table computer(comuter_id int not null primary key auto_increment, This is the working of the JSON function in MariaDB.In which that JSON function interchanges data to match the data type means all attributes in a single form. So MariaDB JSON works on data interpretation.On the other hand, we need to add different attributes into the table that have a different meaning this attribute we consider non – relational attributes.All attributes are in a well-structured format that means all contain of the table are in well suited to relational format. In structural data, we created table names as companies with different attributes.Normally JSON functions work on unstructured data as well as works for data interchange. It is used to check the field of a specified column name. After that, we use the JSON function here we check the function of JSON.In which we created a table with different attributes, as shown in the above statement. In the above syntax, we use a create table statement to implement the MariaDB JSON function.Syntax: create table table_name (colm name 1 data types (size), colm name 2 data types (size), …… colm name N data types (size), check( JSON_VALID(colm Name is or null) )
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |