0

I know I am missing alot, but I am new to mysql and I have to make a table for a used car dealer which includes make,model,price and mpg and I am confused. I have to configure commands with sample data to enter at least one record in each field.


CREATE TABLE cars (
id INT NOT NULL AUTO INCREMENT,
maketext TEXT,
modeltext TEXT,
price
mpg
...
);

Edited by canadian_angel: n/a

5
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by sandeepji1
0

Refer This Sample....

CREATE TABLE IF NOT EXISTS `sample` (
  `NAME` varchar(100) NOT NULL,
  `AGE` int(2) NOT NULL,
  `ADDRESS` text NOT NULL,
  PRIMARY KEY (`NAME`)
);
--
-- Dumping data for table `sample`
--

INSERT INTO `sample` (`NAME`, `AGE`, `ADDRESS`) VALUES
('Ankit', 25, 'Chennai');
0

As we know that MySql act as Database System and we need " Structured Query Language " For Accessing it, and as you mention that not a single column be empty, when anyone insert data in them, fro that we use Constraints Concept,like

CREATE TABLE IF NOT EXISTS Table_Name(NAME VARCHAR(25) NOT NULL,AGE INT(3) NOT NULL,
ADDRESS TEXT NOT NULL, PRIMARY KEY (NAME));

See that Query Carefully, Because here I use Constraints But I don't mention the name for that, then What wrong with me? Nothing Wrong with me.
Because here System automatically insert Constraints Name, but I also have an authority for specifying Constraints name.

Now we Insert one data at one time:
INSERT INTO Table_Name(NAME,AGE,ADDRESS)VALUES("Pradeep", 28,"India");

Now we Insert suppose 4 data at one time??:then we use that Query

INSERT INTO Table_Name(NAME,AGE,ADDRESS)VALUES("Pradeep", 28, "India");
INSERT INTO Table_Name(NAME,AGE,ADDRESS)VALUES("Kuldeep", 23, "India");
INSERT INTO Table_Name(NAME,AGE,ADDRESS)VALUES("Deepak" , 22, "India");
INSERT INTO Table_Name(NAME,AGE,ADDRESS)VALUES("Sandeep", 21, "India");

But that's not so Good, Now we have an Excellent Alternative For that
See Them


INSERT INTO Table_Name(NAME,AGE,ADDRESS)VALUES("Pradeep", 28, "India"),
("Kuldeep", 23, "India"),("Deepak" , 22, "India"),("Sandeep", 21, "India");

Take Enjoy With that Knowledge, and still you have any little bit doubt then just, mention here.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.