CREATE KEYSPACE test WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'datacenter1' : 3 }; USE test; CREATE TABLE airplanes ( name text PRIMARY KEY, manufacturer ascii, year int, mach float ); INSERT INTO airplanes (name, manufacturer, year, mach) VALUES ('P38-Lightning', 'Lockheed', 1937, '.7'); COPY airplanes (name, manufacturer, year, mach) TO 'temp.csv';
1 rows exported in 0.004 seconds.
- Clear the data from the airplanes table and import the data from the temp.csv file.
TRUNCATE airplanes; COPY airplanes (name, manufacturer, year, mach) FROM 'temp.csv';
1 rows imported in 0.087 seconds.
Copy data from standard input to a table.
- Enter data directly during an interactive cqlsh session, using the COPY command defaults.
COPY airplanes (name, manufacturer, year, mach) FROM STDIN;
- At the [copy] prompt, enter the following data:
"F-14D Super Tomcat", Grumman,"1987", "2.34" "MiG-23 Flogger", Russian-made, "1964", "2.35" "Su-27 Flanker", U.S.S.R.,"1981", "2.35" \.
- Query the airplanes table to see data imported from STDIN:
SELECT * FROM airplanes;
Output is:
name | manufacturer | year | mach --------------------+------+--------------+------------- F-14D Super Tomcat | Grumman | 1987 | 2.35 P38-Lightning | Lockheed | 1937 | 0.7 Su-27 Flanker | U.S.S.R. | 1981 | 2.35 MiG-23 Flogger | Russian-made | 1967 | 2.35
No comments:
Post a Comment