Pages

Thursday, August 22, 2013

Drop Table functionality in AlsoSQL(JsonServer plugin of Drizzle)

Do you want to drop table just with the help of json. Now you can do that , recently I have added drop table functionality with json_server plugin.
If you check with Drop table syntax in SQL. You can use drop table in various ways:
  • Drop Table.
  • Drop Table If_exists.
  • Drop Temporary Table.
Json Server allows to drop table in first two ways only.

How you can drop a table?

Its really simple, just start drizzled server with json_server plugin enabled.And then send a curl request to drop a table.

Here is a demo version:
  • Create a schema name as "json" and a table "test" in drizzle database.
  • Now send a HTTP request to drizzle server.
  • curl -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"query":{"schema_name":"json","table_name":"test"}}' 'http://localhost:8086/json/ddl/table/drop'
    
  • HTTP Response.
  • {
       "sql_state" : "00000"
    }
    
  • Send a HTTP request for "DROP TABLE IF_EXISTS [TABLE_NAME]"
  • curl -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"query":{"schema_name":"json","table_name":"test","if_exists":"true"}}' 'http://localhost:8086/json/ddl/table/drop'
    
  • Response should be:
  • {
       "sql_state" : "00000"
    }
    
Drizzle internals doesn't allow identifier::Table to drop a table, they use TableList. So Overload a function with identifier::Table as parameter works for me.

Branch related to this work: lp:~mohyt/drizzle/json_server_table

No comments:

Post a Comment