Beginning SQL

Beginning SQL Beginning SQL

marjan.fesb.hr
from marjan.fesb.hr More from this publisher
20.07.2013 Views

Figure B-29 Click the triangle next to MyTable to see the column named MyColumn listed under MyTable. Now you need to insert some data. There are two records to be inserted. If you enter the statements in the query box, then each INSERT statement must be entered and executed separately, so first type the following into the SQL entry box: INSERT INTO MyTable(MyColumn) VALUES(123); Then click the Execute button, and the data is entered into MyTable. Now clear the SQL entry box and type the following command, and click Execute: INSERT INTO MyTable(MyColumn) VALUES(888); However, an easier alternative when you have to write more than one SQL statement is to write the code in the script box. Choose New Script Table from the File menu. Now type both lines into the script box, which is the large lower textbox that has now been created. Make sure that you end each statement with a semicolon, as shown in the preceding code. Once you’ve entered both lines, click the Execute button on the toolbar just above the script textbox. To see what data is in MyTable, clear the SQL entry box and execute the following SELECT statement: SELECT * FROM MyTable You should see the screen that appears in Figure B-30: Setting Up and Using the Five Database Systems 407

Figure B-29<br />

Click the triangle next to MyTable to see the column named MyColumn listed under MyTable.<br />

Now you need to insert some data. There are two records to be inserted. If you enter the statements in<br />

the query box, then each INSERT statement must be entered and executed separately, so first type the following<br />

into the <strong>SQL</strong> entry box:<br />

INSERT INTO MyTable(MyColumn) VALUES(123);<br />

Then click the Execute button, and the data is entered into MyTable. Now clear the <strong>SQL</strong> entry box and<br />

type the following command, and click Execute:<br />

INSERT INTO MyTable(MyColumn) VALUES(888);<br />

However, an easier alternative when you have to write more than one <strong>SQL</strong> statement is to write the code<br />

in the script box. Choose New Script Table from the File menu. Now type both lines into the script box,<br />

which is the large lower textbox that has now been created. Make sure that you end each statement with<br />

a semicolon, as shown in the preceding code. Once you’ve entered both lines, click the Execute button on<br />

the toolbar just above the script textbox.<br />

To see what data is in MyTable, clear the <strong>SQL</strong> entry box and execute the following SELECT statement:<br />

SELECT * FROM MyTable<br />

You should see the screen that appears in Figure B-30:<br />

Setting Up and Using the Five Database Systems<br />

407

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!