Solved

"Create Table" query for MS Access Databases

Posted on 2004-09-02
12
368 Views
Last Modified: 2008-03-17
Hi again,

    I've two questions to ask

1 - Can we use the use the "Create table" query to make new tables within our database? Make sure I'm talking about MS Access Database. If we can, then what syntax shall be used to create table n how the datatypes must be defined. Moreover, if I use a field that receives the input string as Integer and it gets out of the integer range, then how we shall arrange the field. In Access we can simply do that by setting the "Field Size" to double n add the no. of decimal places. Hw it shall be used while creating a data field?


2 - Secondly, if the database is already ready, but missed to add one more field within it, then what syntax shall I use to add the missing field in the already exisiting database? Lets say I made a database named "Profile.mdb" containing "FName", "Lname" as basic fields but I need to add one more field within it using the online script. Then I definitely won't update the databse back again to overwrite the past one. What alternate shall be used instead of uploading to add our required fields within the exiting n uploaded database?

           Will wait for ur replies. Bye
0
Comment
Question by:adnan_from_hiit
  • 4
  • 4
  • 4
12 Comments
 
LVL 3

Assisted Solution

by:Ayesha_K
Ayesha_K earned 25 total points
ID: 11962502
to run queries go to Query tab in access ... click on New ... on the top of the NEW window right click ... and click on SQL View ... paste these queries there one by one ... and click on the red ! icon at the top ...

1- create table TestTable (TestInt integer Primary Key, testCharacter varchar(50));

2- alter table TestTable
add column TestNewColumn varchar(30)
0
 

Author Comment

by:adnan_from_hiit
ID: 11962647
thanx Ayesha n what abt creating field accept integer value as Double(Field Size)
0
 
LVL 3

Expert Comment

by:Ayesha_K
ID: 11962690
2- alter table TestTable
add column TestNewColumn1 float
0
 

Author Comment

by:adnan_from_hiit
ID: 11963030
thanx once again... any idea of renaming the existing data field within a table and to rename a table
0
 
LVL 11

Expert Comment

by:sciber_dude
ID: 11963134
You could open access, single click on the table name TWICE and rename it.

also select the table and click Design ... and you can add a variable or edit the variable names / types.

Make sure that if you edit the variable type, you may lose data.

:) SD
0
 
LVL 11

Expert Comment

by:sciber_dude
ID: 11963160
Here is more info if you need to Alter the table.

ALTER TABLE table
{ADD {COLUMN field type[(size)] [NOT NULL] [CONSTRAINT index] |
CONSTRAINT multifieldindex} |
DROP {COLUMN field | CONSTRAINT indexname} }

http://www.devguru.com/Technologies/jetsql/quickref/alter_table.html
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:adnan_from_hiit
ID: 11963165
I'm asking to change it using online script not manually

I'm already aware of that

I've tried RENAME TABLE F1 TO F2

It changes the table name

what to do to change the data field in existing table
0
 

Author Comment

by:adnan_from_hiit
ID: 11963181
any idea ????
0
 
LVL 3

Expert Comment

by:Ayesha_K
ID: 11963195
0
 
LVL 11

Expert Comment

by:sciber_dude
ID: 11963202
One way to rename a column in Access is ...

sql = "ALTER TABLE MyTable ADD NewName VARCHAR(50)"

sql = "UPDATE MyTable SET NewName = OldName"

sql = "ALTER TABLE MyTable DROP OldName"

Coz "rename column" doesnt work in Access

Also here is more info on renaming tables. http://www.4guysfromrolla.com/webtech/tips/t030802-1.shtml
0
 
LVL 11

Accepted Solution

by:
sciber_dude earned 25 total points
ID: 11963252
This changes the variable type of the column

ALTER TABLE tablename MODIFY (
          columname type(length)
) ;

0
 
LVL 3

Expert Comment

by:Ayesha_K
ID: 11963359
The clauses to rename columns and tables are Postgres extensions from SQL92.  

that is why we can not simply rename tables and columns through the rename command as we do in SQL Server or oracle.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Passing special characters in http get request 7 39
SQL Filter Question 8 79
Need help to rewrite script 3 68
IP API - need data... 4 13
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now