rename

The rename operator changes the array name.

Synopsis

rename(current_array_name, new_array_name);

Summary

The AFL rename operator changes the name of an array.  The behaviour is similar to using the Unix mv (move) command.

Inputs

  • current_array_name: An array that was previously created and stored in the SciDB database.
  • new_array_name: The new name for the array

Examples

To create an array named source, show its name and schema, rename it, and show its new name and schema, do the following. Note that the array ID remains the same.

  1. To create the array named source, enter:

    AFL% store(build(<val:double>[i=0:9],1),source);


    The output is:

    {i} val
    {0} 1
    {1} 1
    {2} 1
    {3} 1
    {4} 1
    {5} 1
    {6} 1
    {7} 1
    {8} 1
    {9} 1
  2. To show the list of arrays, and the respective schemas, enter:

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


    The output is:

    {No} uaid,name,schema
    {0} 47,'source','source<val:double>[i=0:9:0:1000000]' 

    Note that the value for uaid may change.
     

  3. To rename the array, enter:

    AFL% rename(source,target); 


    The output is:

    Query was executed successfully
  4. To show the list of arrays, and the respective schemas, enter:

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


    The output is:

    {No} uaid,name,schema
    {0} 47,'target','target<val:double>[i=0:9:0:1000000]'

    Note the name changes from source to target.  The uaid matches the uaid from step two.


  5. To remove the array, enter:

    AFL% remove(target);    


    The output is:

    Query was executed successfully


Unlike many operators, rename does not create a new array version but rather renames all existing versions of the specified array. To demonstrate, do the following:

  1. Create the first version of array A by entering:

    AFL% store(build( <val:int64>[i=0:3; j=0:1],i*4+j),A);


    The output is:

    {i,j} val
    {0,0} 0
    {0,1} 1
    {1,0} 4
    {1,1} 5
    {2,0} 8
    {2,1} 9
    {3,0} 12
    {3,1} 13

     

  2. Create the second version of array A by entering:

    AFL% store(build(A,i*3+j),A); 


    The output is:

    {i,j} val
    {0,0} 0
    {0,1} 1
    {1,0} 3
    {1,1} 4
    {2,0} 6
    {2,1} 7
    {3,0} 9
    {3,1} 10
    
    
  3. Create the third version of array A by entering:

    AFL% store(build(A,i*2+j+1),A); 


    The output is:

    {i,j} val
    {0,0} 1
    {0,1} 2
    {1,0} 3
    {1,1} 4
    {2,0} 5
    {2,1} 6
    {3,0} 7
    {3,1} 8
  4. Show the details of all the versions for all arrays:

    AFL% project(list('arrays',true), name, schema);


    The output is:

    {No} name,schema
    {0} 'A','A<val:int64>[i=0:3:0:1000; j=0:1:0:1000]'
    {1} 'A@1','A@1<val:int64>[i=0:3:0:1000; j=0:1:0:1000]'
    {2} 'A@2','A@2<val:int64>[i=0:3:0:1000; j=0:1:0:1000]'
    {3} 'A@3','A@3<val:int64>[i=0:3:0:1000; j=0:1:0:1000]'
  5. Rename array A to Octagon:

    AFL% rename(A,Octagon);  


    The output is:

    Query was executed successfully
  6. Show the details of all the versions for all arrays:

    AFL% project(list('arrays',true), name, schema);


    The output is:

    {No} name,schema
    {0} 'Octagon','Octagon<val:int64>[i=0:3:0:1000; j=0:1:0:1000]'
    {1} 'Octagon@1','Octagon@1<val:int64>[i=0:3:0:1000; j=0:1:0:1000]'
    {2} 'Octagon@2','Octagon@2<val:int64>[i=0:3:0:1000; j=0:1:0:1000]'
    {3} 'Octagon@3','Octagon@3<val:int64>[i=0:3:0:1000; j=0:1:0:1000]'


  7. Remove the Octagon array:

    AFL% remove(Octagon);

    The output is:

    Query was executed successfully



    Â