System Administration Guide: Naming and Directory Services (NIS+)

Adding Entries to an NIS+ Table

To add new entries (rows) to a table, use nistbladm with either the -a or -A options followed by either one or more column=value pairs and the table name or an indexed name as described in nistbladm and Indexed NIS+ Names.


nistbladm [-a | -A] indexedname
nistbladm [-a | -A] column="value" \
column="value" \
... tablename

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


Note –

NIS+ is a naming service and its tables are designed to store references to objects, not the objects themselves. NIS+ is optimized to support 10,000 objects with a combined total size of all tables not more than 10M bytes. NIS+ does not support individual tables where the sum of field sizes in a single column are greater than approximately 7k. If a table is too large, rpc.nisd may fail.


Adding an NIS+ Table Entry With the -a Option

The -a option adds an entry to a table unless the entry already exists, in which case it returns an error. An entry is defined as existing if its values in the searchable columns exactly match the values in the new entry's searchable columns. (The values in non-searchable columns are not taken into account.)

To use the -a option, you must specify a value for every column in the table:


nistbladm -a column="value" \
 column="value" \
 ... tablename
nistbladm -a indexedname

(To list the names and characteristics of table columns, use the niscat -o tablename command.)

For example, to add a new row to a table named depts using column=value pairs, you would enter:


rootmaster% nistbladm -a Name='R&D' Site='SanFran' \
 Name='vattel' depts.doc.com.

To add the same entry using an indexed name, you would enter:


rootmaster% nistbladm -a [Name='R&D',Site='SanFran',\
 Name='vattel'],depts.doc.com.

Both examples would produce a table row that looked like this:

Dept 

Site 

Name 

R&D 

SanFran 

vattel 

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

You can only add one entry with each instance of the nistbladm command. You must run nistbladm once for each entry row you want to add.

If a table row already exists with values in each column that are identical to the entry you are trying to create, nistbladm -a will return an error. You cannot have two identical entry rows in a table. In this context, rows are considered identical if the values in the searchable columns are identical, the values in none search able columns are not considered.

For example, if the Dept and Site columns are searchable, and the Name column is not searchable, nistbladm considers the following two rows to be identical:

Dept (searchable) 

Site (searchable) 

Name (not searchable) 

Sales 

Vancouver 

Hosteen 

Sales 

Vancouver 

Lincoln 

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 an NIS+ 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