set_namespace

The set_namespace operator sets the current namespace to be used. Available only in the Enterprise Edition.

SciDB security mode must be correctly configured before this or any security operator can be used.  See the Security section of the SciDB Administration Guide.

For backward compatibility, namespace names may appear inside single quotes. The quotes are no longer needed, and quoted namespace names may not be supported in future releases.

Synopsis

set_namespace(name);

Inputs

  • name – Name of a namespace to select as the current working namespace.

Summary

The set_namespace operator changes the working namespace to a new namespace. After the new namespace has been set, any operator that works with unqualified array names looks for those arrays in the new namespace.  Arrays  not in the working namespace must be accessed using fully qualified array names.

The current working namespace is valid only for the duration of the database connection.  When a SciDB client application such as iquery first connects to the database, the current working namespace is set to the public namespace.

Any user with list permission for the namespace can invoke this operator.

Example

To see the set_namespace() operator in action, do the following:

  1. Set the working namespace to public:

    AFL% set_namespace(public); 


    The output is:

    Query was executed successfully
  2. Create an array in the public namespace called public_array:

    AFL% create array public_array <v:int32>[i=0:9];


    The output is:

    Query was executed successfully
  3. List the arrays in the public namespace:

    AFL% project(list(), name, schema, namespace);


    The output is:

    {No} name,schema,namespace
    {0} 'public_array','public_array<v:int32>[i=0:9:0:*]','public'
  4. Create a namespace called NS1:

    AFL% create_namespace(NS1);


    The output is:

    Query was executed successfully
  5. Set the working namespace to NS1:

    AFL% set_namespace(NS1); 


    The output is:

    Query was executed successfully
  6. Create an array called ns1_array:

    AFL% create array ns1_array <v:int32>[i=0:9];


    The output is:

     Query was executed successfully
  7. List the arrays in the NS1 namespace:

    AFL% project(list(), name, schema, namespace);


    The output is:

    {No} name,schema,namespace
    {0} 'ns1_array','ns1_array<v:int32>[i=0:9:0:*]','NS1'

    The public_array is not listed because that is in the public namespace and not the NS1 namespace.

  8. List arrays in all namespaces:

    AFL% project(list(ns: all), name, schema, namespace);

    The output is:

    {No} name,schema,namespace
    {0} 'ns1_array','ns1_array<v:int32> [i=0:9:0:*]','NS1'
    {1} 'public_array','public_array<v:int32> [i=0:9:0:*]','public'
  9. Set the working namespace to public:

    AFL% set_namespace(public); 


    The output is:

    Query was executed successfully
  10. List the arrays in the public namespace:

    AFL% project(list(), name, schema);


    The output is:

    {No} name,schema
    {0} 'public_array','public_array<v:int32>[i=0:9:0:*]'

    The ns1_array is not listed because that is in the NS1 namespace and not the public namespace.

  11. Remove the array NS1.ns1_array:

    AFL% remove(NS1.ns1_array);

    The fully qualified array name is required because the current working namespace is public and not NS1.

    The output is:

    Query was executed successfully
  12. Remove the NS1 namespace:

    AFL% drop_namespace(NS1);


    The output is:

    Query was executed successfully
  13. Remove the array public.public_array:

    AFL% remove(public_array);

    The fully qualified array name is not required because the current working namespace is public.

    The output is:

    Query was executed successfully