Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 06-11-2009
Member
 
Join Date: Nov 2009
Posts: 566
Structure of Table in MySQL

Hi,
I am stuck on creating table in MySQL database. I want to add up some new records in a existing database. Here I am trying to create a new table. The problem is that I am not familiar with the syntax used for the same, due to which I cannot put new records and then link the same to other tables. Can anyone post the structure of tables in SQL. And if possible how to build SQL cursors. This is a thing I want to learn right now. Thanks in advance.
Reply With Quote
  #2  
Old 06-11-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: Structure of Table in MySQL

For creating a new table you will have to pass on the following syntax. CREATE TABLE table ( field1 type (size) Picture 1, field2 type (size) Picture 2, ... , multifield index, ... ). It is a sample syntax for the process. The explanation for the same is here. The table - Is the name of the table being created. The field1 field2 - Is the name of the field or fields that will be created in the new table. The new table must contain at least one field. The type - It's the kind of field data in the new table. The size - Is the size of the field only applies to text fields. The Picture 1 Picture 2 - Constraint is a clause that defines the type of index to create. This optional clause. And the multifield index - Constraint is a clause that defines multifield index type to create. A multifield index is one that is indexed by the contents of various fields. This optional clause.
Reply With Quote
  #3  
Old 06-11-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: Structure of Table in MySQL

Here is a sample work for creating a table in MySQL. This will help you to generate user modified tables which are easy to access. First use the following syntax. CREATE TABLE Employees ( Name Text (25), Last Name TEXT (50) ). Then lets take a example the you are creating a a new table named Employees with two fields, one called Name in text and longitude 25 and another called names with length 50. The syntax for the same is CREATE TABLE employees ( Name TEXT (10) Surname TEXT BirthDate DATETIME )CONSTRAINT IndiceGeneral UNIQUE ( Name, Surname, BirthDate )
Reply With Quote
  #4  
Old 06-11-2009
Member
 
Join Date: May 2008
Posts: 2,383
Re: Structure of Table in MySQL

In some Databases it is possible to open a data cursors within the working environment, typically used stored procedures. The syntax for a cursor is as follows: DECLARE name-cursor FOR specification-consultation [ORDER BY]. Like for example - DECLARE Ab_Cursor FOR Num_emp SELECT name, position, salary FROM employee WHERE DEPT_NUM = 'COMPUTER'.
Reply With Quote
  #5  
Old 06-11-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
Re: Structure of Table in MySQL

You use the CONSTRAINT clause in ALTER TABLE and CREATE TABLE to create or delete indexes. There are two syntax's for this clause depending on whether you want to create or delete an index in a single field or if it is a multi-index field. If you use the Microsoft Data Engine, you can only use this term with the proprietary database of the motor. For single-field index: CONSTRAINT name (PRIMARY KEY | UNIQUE | REFERENCES external table [(externo1 field, field externo2)]) and for multiple field indexes CONSTRAINT name (PRIMARY KEY (primario1 [, primario2 [,...]]) | UNIQUE (?nico1 [, ?nico2 [, ...]]) | FOREIGN KEY (ref1 [, ref2 [,...]]) REFERENCES external table [(externo1 field, field externo2 [,...])]}.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Structure of Table in MySQL"
Thread Thread Starter Forum Replies Last Post
What are the Table Types in MySQL? Dino M Software Development 7 29-10-2010 05:18 PM
C++ table structure RyanInt Software Development 3 14-11-2009 07:50 PM
How to Insert data into MySQL table Mahendra varma Software Development 4 04-10-2009 04:42 AM
How to repair MySQL table? Suzane Software Development 3 05-09-2009 11:50 AM
About mysql table subqueries Benito Software Development 2 04-08-2009 06:07 PM


All times are GMT +5.5. The time now is 10:47 PM.