How to run created table with data SQL?
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
Re: How to run created table with data SQL?
to view the data you need to run a command like:
SELECT * FROM course;
Re: How to run created table with data SQL?
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
Re: How to run created table with data SQL?
Quote:
but is the coding correctly typed in.
Yes, it looks OK
Quote:
The command you gave do i type it into the terminal?
Yes
Re: How to run created table with data SQL?
I typed in SELECT * FROM course; command but all i got was an error command not found?????
Re: How to run created table with data SQL?
try putting the command in the file at the end
Re: How to run created table with data SQL?
lol now it keeps saying no match.
Re: How to run created table with data SQL?
I managed to get it working but doing a couple of things thanks for your help.
Re: How to run created table with data SQL?
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.
Re: How to run created table with data SQL?
Download phpmyadmin.
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.