PDA

View Full Version : How to run created table with data SQL?



Flametongue
04-25-2005, 11:30 AM
Hi I am new to all of this creating tables using SQL. I usally do database stuff with access. I have created this table and included some data but how do i run it so i can view the table with its data. I am using emacs on a computer that has unix btw. Here is what i typed in. Is this correct and how do i run it.

CREATE TABLE course(
coursecode CHAR(5) NOT NULL,
title CHAR(25),
school CHAR(15),
PRIMARY KEY (coursecode));

INSERT INTO course VALUES
('AB12', 'Civil Engineering', 'Engineering');
INSERT INTO course VALUES
('CE65', 'Computer Science', 'Computing');

Cheers

ObiWan
04-25-2005, 11:55 AM
to view the data you need to run a command like:

SELECT * FROM course;

Flametongue
04-25-2005, 12:05 PM
but is the coding correctly typed in. Also when your write the coding for the tables and the data thats going to be entered when you want to update or add something does that coding need to be added in that same file. Also when making queries do you need to write the coding in same file or new new. The command you gave do i type it into the terminal?

Cheers

ObiWan
04-25-2005, 06:21 PM
but is the coding correctly typed in.
Yes, it looks OK

The command you gave do i type it into the terminal?
Yes

Flametongue
04-25-2005, 06:39 PM
I typed in SELECT * FROM course; command but all i got was an error command not found?????

ObiWan
04-25-2005, 06:48 PM
try putting the command in the file at the end

Flametongue
04-25-2005, 08:05 PM
lol now it keeps saying no match.

Flametongue
04-25-2005, 09:12 PM
I managed to get it working but doing a couple of things thanks for your help.

4play
04-25-2005, 09:15 PM
normally you have to login to the mysql server first then select the database you want then you can select the data you want from it.

sorry its been a very long time since i used it so i have forgot the commands.

tesco
04-25-2005, 09:43 PM
Download phpmyadmin (http://www.phpmyadmin.net/home_page/).
it makes running sql queries soooo much easier.
once you have it and have configured it to connect to mysql, open it up (in web browser) and create a new database, then click on "SQL" at the top and paste that code in then submit.