How to save contents? [message #401281] |
Sun, 03 May 2009 18:05 |
Konfused
Messages: 2 Registered: May 2009
|
Junior Member |
|
|
Hi im quite (very!) new to SQL and Oracle,
basically in the command line, i have created a few tables, and inserted the relevent data..
I want to know how to 'save' everything I have done so far, so I can resume it tomorrow for example
We've been told (school) to use 'SPOOL c:\name.txt' or 'ed c:\name.sql' to do this, but it doesnt seem to work.
Also i was reading around, and came across the 'COMMIT' function which saves the data also?
Any help would be appreciated
Thanks
|
|
|
|
Re: How to save contents? [message #401306 is a reply to message #401281] |
Mon, 04 May 2009 00:35 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
As a newbie, you'd perhaps want to save all statements you've used in a file. SPOOL can't do that, so - use editor of your choice (such as Notepad on MS Windows) and put CREATE TABLE, INSERT INTO, ... in there so that you'll be able to review them later. There is a way to create all of these afterwards, but - as a newbie (again) - this is probably not what you should do now.
If overnight noone recreates schema you are working on, COMMIT will save data you've entered and/or modified so, in the morning, you'll find everything just as you've left yesterday afternoon. If not, you'll use file saved in the first paragraph of this message to set the whole environment up again.
|
|
|
Re: How to save contents? [message #401355 is a reply to message #401306] |
Mon, 04 May 2009 04:22 |
Konfused
Messages: 2 Registered: May 2009
|
Junior Member |
|
|
Thanks for the help,
When you say
use editor of your choice (such as Notepad on MS Windows) and put CREATE TABLE, INSERT INTO,
Would i have to enter it myself manually or is there a command i can type in the command line to do this, (assuming i've entered all of this in the command line before hand)
|
|
|
|
Re: How to save contents? [message #404509 is a reply to message #401355] |
Fri, 22 May 2009 01:03 |
|
Barbara Boehmer
Messages: 9100 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
There is probably already a default editor set up. So, if, from the SQL*Plus command prompt you type:
ed c:\name.sql
it should open up a window that you can type in. You can put your create table, insert, and commit commands in there and save them. You can also add spool commands to spool the results to a file when you run the c:\name.sql. There should be a drop-down menu at the top where you can select file and save when you are done. So, if you enter something like:
spool c:\name.txt
drop table your_table;
create table your_table (your_column number);
insert into your_table (your_column) values (1);
commit;
spool off
and save it, then when you run it by typing from SQL*Plus:
start c:\name.sql
your table will be created, your data will be entered and saved, and the results will be spooled to a file c:\name.txt which you can then view by typing:
ed c:\name.txt
|
|
|