bcp NURSE in nurses.txt -U mary -P MYPW -c -t , -r \\ncopies into the preexisting relation NURSE the tuples specified in the data file nurses.txt. The user here is mary with Sybase password MYPW. The ``-c'' option means the data file is in ASCII characters, ``
-t ,'' means components within a
tuple are separated by the ``,'' character, and ``-r
\\n'' means each tuple in your data file is terminated by a newline
character. For more information on bcp, use sybooks or the
syman command. select * from REL-NAME
\go
You can delete all tuples in a relation (but not the relation itself)
by invoking the Sybase SQL command:
delete from REL-NAME
\go
The following is a trace that illustrates the creation of a relation, bulk loading a data file into the database, checking the relation, and deleting all tuples from the relation.
elaine35:~> cat nursecreate
create table NURSE
(EmpID int,
SSN char(12),
Name char(20))
\go
elaine35:~> cat nurses.txt
101, 415-49-1234, Gina
48, 618-37-9876, Jane
2, 911-68-1357, Jill
elaine35:~> sqsh -U mary -P MYPW < nursecreate
elaine35:~> bcp NURSE in nurses.txt -U mary -P MYPW -c -t , -r \\n
Starting copy...
3 rows copied.
Clock Time (ms.): total = 1 Avg = 0 (3000.00 rows per sec.)
elaine35:~> sqsh -U mary -P MYPW
sqsh-1.2 Copyright (C) 1995, 1996 Scott C. Gray
This is free software with ABSOLUTELY NO WARRANTY
For more information type '\warranty'
1> select * from NURSE
2> \go
EmpID SSN Name
----------- ------------ --------------------
101 415-49-1234 Gina
48 618-37-9876 Jane
2 911-68-1357 Jill
(3 rows affected)
1> delete from NURSE
2> \go
(3 rows affected)
1> select * from NURSE
2> \go
EmpID SSN Name
----------- ------------ --------------------
(0 rows affected)
1> \quit
elaine35:~>