Home | About | Contact | Feed Subscription | Submit Article | Link exchange | Translate(google) to:





MySQL basic commands part 2


E-mail this post



Remember me (?)



All personal information that you provide here will be governed by the Privacy Policy of Blogger.com. More...



first, srry fot not posting for a few days, i have had few personal problems...
-----------------------------------------------------------------------------------

note: USE database command is one of commands that doesn't need ; sign for marking end of command.

-----

Now when we have selected specific database with command USE, we now that there is no tables in it. You should know that datas in databases like MySQL are stored in tables, where every atribut has its data type.

We'll create table, with command that is logical: CREATE name_of_table ()
Inside () we are putting atributed and defining its data types.
Here we will present few data types, through our example, but if you want to see all of them and their use, check MySQL specification reference.
For our students table we will put in there theirs: name, surname, height, weight, birth.
For name, surname we will use varchar() type of data. In () we are putting max number of characters that name or surname can have.
For height and weight we will use float (decimal) number type
For birth we will use date type of data where type of date is: YYYY-MM-DD by default.

In this table setting of primary keys is not covered because, here I'm tring to explain very basics. Primary key and relations will be covered after this and few more topics.

So here is our command:
CREATE TABLE person (name varchar(15), surname varchar(20), height float, weight float, birth date);
To see weather is everything ok about data types we'll use this command:
-> DESCRIBE name_of_table; or DESC name_of_table;



Now, we need to fill that table. We'll use technique of importing .txt file into our table. For that we need to create .txt file 'C:\file.txt' where will be few lines of our datas. Every row will have data orderd by atributes and separated by 1 TAB.

exemple of 1row of txt file:
name1 (1 TAB separation) surname1 (1 TAB separation) height (1 TAB separation) weight (1 TAB separation) birth (1 TAB separation) \r\n

\r\n is string that is used for end of row, so command can recognise end of 1 row

Syntax of commands that imports .txt file into table is:
LOAD DATA LOCAL INFILE 'C:/path_to_file' INTO TABLE name_of_table LINES TERMINATED BY '\r\n';

note: when putting path of file use sign / for separating between folders or drives, not \ as it is common in Windows Explorer

After this we'll check to make sure that all datas are correctly imported.

SELECT * FROM name_of_table;



-----
new post very soon

other parts about MySQL:
MySQL basic commands part 1
MySQL basic commands part 3
MySQL basic commands part 4




0 Responses to “MySQL basic commands part 2”

Leave a Reply

      Convert to boldConvert to italicConvert to link

 




    Free Image Hosing :: www.slibe.com



History:

Graphics Cards

Introduction
History
Working Method
GPU
Video Memories
Arhitecture
Graphics card types
PCI

OpenGL

Introduction to OpenGL
OpenGL history
OpenGL vs. Direct3D
Fahrenheit
OpenGL tutorials

Computer Graphics

History of Computer Graphics
3D Terms
Computer Graphics part 1

Posts about Linux

Installing from source code
Konsole-Shell part 1
Novell SuSe Linux part 2 - Installing nvidia graphics drivers
Novell Suse 9.3 GNU/Linux part 1

Posts about MySQL

MySQL Basic Commands part 1
MySQL Basic Commands part 2
MySQL Basic Commands part 3
MySQL Basic Commands part 4

Other Posts

First Post

Archives:

Links:

  • Blogger Templates
  • Digital Computing Machines
  • Mysterie World
  • NeHe OpenGL


Copyleft 2006 :: The place where you can be free :: Beyond Computing | Mysterie World | Digital Computing Machines
Powered by Blogger, Blogger Beta, Blogger Templates and Slibe :: Free Image Hosting