Showing posts with label MySQL Tutorial for Beginners. Show all posts
Showing posts with label MySQL Tutorial for Beginners. Show all posts

Saturday, December 3, 2011

Add Data to Tables in a Database

After you have created a table in database the next step is to add data to that table.Now the data that you will add to the table may consist of one, more than one but less than the required number or all of the parameters specified in the table.The number of parameters depends upon the actions and also the scripts that you are executing and it differs from case to case.

To simplify if you want to add username and password but put all other parameters optional in your script than the data is added to the table inside the database only when a username and a password is entered.In that case it doesn't matter if all other fields are left blank or filled.So basically, by putting up various conditions you can add data to tables in multiple number of ways.

For Adding data to tables - 

INSERT INTO table_name(field1, field2, field3) VALUES('value1', 'value2', 'value3');


To view table content - 
SELECT * from table_name;


Wednesday, November 16, 2011

Create a Database and Add Tables to it in MySQL Command Line

MySQL is one of most basic database application language and is very easy to deal with. The applications of MySQL go in hand to hand with any scripting language.It is very much useful to deal with situations where data manipulation is to be specific and ordered.
Various commands are given below:
*Connecting to a database---mysql -u username -p password -h hostname It is by default mysql -u root -p -h 127.0.0.1;
*Seeing the different databases present---show databases;
*Creating a database---create database database name;
*Creating tables---create table table_name(parameters);