Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
19.  Administering NIS+ Tables Adding Entries to a Table Adding a Table Entry With the -a Option  Previous   Contents   Next 
   
 

In this example, nistbladm -a would not allow you to create the Sales Vancouver Lincoln row.

However if just some of the searchable columns have values identical to the entry you are trying to create, nistbladm -a will create a new entry as specified. For example, you could run the following commands to create two similar, but not identical, rows in a depts table:

rootmaster% nistbladm -a Dept='Sales' \
   Site='Vancouver' Name='hosteen' staff.doc.com.
rootmaster% nistbladm -a Dept='Sales' \
   Site='SanFran' Name='lincoln' staff.doc.com.

Which would produce rows that had some, but not all identical values in the searchable columns:

Dept

Site

Name

Sales

Vancouver

hosteen

Sales

SanFran

lincoln

Adding a Table Entry With the -A Option

The -A option is designed for applications where you need to force nistbladm to overwrite an existing entry. Like the -a option, -A adds a new entry to a table. However, if the entry already exists, instead of exiting with an error, it overwrites the existing entry row.

When using the -A option, you must specify all columns in the entry.

For example, suppose the following table exists and the Dept and Site columns are searchable:

Dept (searchable)

Site (searchable)

Name

Sales

SanFran

Lincoln

Now you run the following command:

rootmaster% nistbladm -A Name=Sales Site=SanFran \
 Name=Tsosulu depts.doc.com.

The -a option would have returned an error, since the entry specified by Name=Sales Site=SanFran already exists. But the -A option allows you to overwrite the existing row.

Dept

Site

Name

Sales

SanFran

Tsosulu

Modifying Table Entries

Existing table entries are edited (modified) using either the -e or -E options. The Solaris operating environment release also supports use of the -m option for backwards compatibility with earlier releases. (All new applications and command line operations should use either the -e or -E options.)

To edit an existing entry (row) in a table, use nistbladm with either the -e or -E options followed by one or more column=value pairs that specify the new values and ending with an indexed name that identifies a particular row in a table as described in "nistbladm and Indexed Names".

nistbladm [-e | -E] column="value" \
 column="value" \
 ... indexedname

When adding new entry rows to a table with either -e or -E:

  • Always enclose the value element in quotes. For example, to change the value of the cname column to deneb, the column=value pair would look like: cname="deneb"

  • You can only edit values in searchable columns one entry (row) at a time.

  • To specify that a column in the entry row that you are editing be empty, use column=" ". In other words, for the value, enclose a space between the quote marks.

Editing a Table Entry With the -e Option

The -e option edits an entry in a table unless doing so would result in changing values in searchable columns in more than one entry row, in which case it returns an error. (The values in non-searchable columns are not taken into account.)

nistbladm column="value" \
 column="value" \
 ... indexedname

To use the -e option, you only need to specify the column values you are changing.

For example, suppose you had the table:

Dept

Site

Name

Sales

SanFran

Tsosulu

To change the value of the Name column to Chandar, you would enter:

master% nistbladm -e Name="Chandar" [Dept='Sales',Site='SanFran'],\
 depts.doc.com.

Now the table looks like this:

Dept

Site

Name

Sales

SanFran

Chandar

(Note that in the example above, the indexed name did not need to include the Name column because in these examples that column is not searchable.)

C-shell users should also use quotes to set off expressions using square brackets.

You can use the -e option to edit the values in searchable columns so long as the new values you specify affect only the single row identified by the indexed name. For example, to change the department to Manf, you would enter:

master% nistbladm -e Dept="Manf" [Dept='Sales',Site='SanFran'],\
 depts.doc.com.

Dept (searchable)

Site (searchable)

Name

Manf

SanFran

Chandar

However, if an entry row already existed with Manf and SanFran in the searchable columns, the -e option would return an error.

You can specify changes to multiple columns so long as they all apply to a single entry row. For example, to change both the Dept and Name values, you would enter:

master% nistbladm -e Dept="Manf" Name="Thi" \
 [Dept='Sales',Site='SanFran'],depts.doc.com.

Dept (searchable)

Site (searchable)

Name

Manf

SanFran

Thi

Editing a Table Entry With the -E Option

The -E option is designed for applications where you need to force nistbladm to overwrite an existing entry even if doing so will affect more than one entry.

For example, suppose your table had the following rows:

Dept (searchable)

Site (searchable)

Name

Sales

SanFran

Chandar

Sales

Alameda

Achmed

Now you run the following command:

master% nistbladm -E Site="Alameda" Mgr="Chu" \
[Div='Sales',Site='SanFran'],depts.doc.com.

Which would change the Sales SanFran Chandar row to Sales Alameda Chu. But Sales Alameda are the key values identifying the Sales Alameda Achmed row, so that row would also be changed. The result would be a single row where once there had been two rows:

Dept (searchable)

Site (searchable)

Name

Sales

Alameda

Chu

The -e option would have returned an error, since the edit would affect more than one row. But the -E option allows you to affect more than one entry row.

Removing Table Entries

 
 
 
  Previous   Contents   Next