Updating A Database's Tables

Pages: 1, 2
free web hosting
Free Web Hosting > Computers & Tech > Databases

Updating A Database's Tables

nightfox
Is there an "easy" way to update a database's tables? Like for instance, I have my own custom-coded member login system. Whenever I add a new feature that needs a database, I manually have to download, update and upload the database. Is there an easy way I can do this?

THANKS!!!

[N]F

Reply

yordan
Usually, it's rather easy to update a table in a database.
The syntax is something like "insert into MYTABLE values SOMETHING, SOMETHING_ELSE, ..."
Was this your exact question ?

Reply

Hercco
What Yordan posted was inserting a record to the database and I don't think Nightfox is after that.

You are looking to change the tables structure right? Updating in database world usually means updating a single record which is done with SQL command beginning with UPDATE keyword or command or whatever.

You can do all possible operations to a database with queries. Sometimes certain features might be limited (for example dropping databases might not be allowed from PHP scripts and so on) but usually you should be able to change the structure. Well provided that the user has create rights.

Basically how you do it is use ALTER TABLE query. For example you can add column with query like this "ALTER TABLE tablename ADD column type". Naturally the syntax is exactly the same as for creating tables so you can everything here you can do there. You can drop columns with "ALTER TABLE tablename DROP COLUMN columnname".

It is also possible to rename and change datatypes for columns, but unless I'm completely mistaken the syntax varies from DBMS to DBMS. MySQL uses CHANGE "ALTER TABLE tablename CHANGE oldname newname type". Notice that you can change the type here. To just change the type keep the name same.

I have a vague memory that Oracle uses RENAME... I could be wrong though.



I hope this answers your question.

 

 

 


Reply

yordan
Nicely answered, Hercco.
I must confess that i was confused by the topic title, I understood the " Updating A Database's Tables" by updating some rows in a table, which is different from insert but thas nothing to do with the ALTER TABLE notion.
Sorry again
Yordan

Reply

nightfox
QUOTE(Hercco @ Jun 1 2006, 09:25 AM) *

What Yordan posted was inserting a record to the database and I don't think Nightfox is after that.

You are looking to change the tables structure right? Updating in database world usually means updating a single record which is done with SQL command beginning with UPDATE keyword or command or whatever.

Thanks!! I'll look into all of that. It does look like what I'm after. I use MySQL, not Oracle. But thanks again!!

[N]F

Reply

Chesso
I'm pretty sure most if not all database software accepts pretty much the exact same syntax or close to it. I would say UPDATE is what you are looking for, it basically let's you change a field in a table to my knowledge to say update a int value incrementaly and such.

INSERT would allow you to insert a new field in the table or record either way, by id or if the table has an auto_incremental primary key then it would do it automatically.

I don't know of ALTER though? it sounds like it does the same thing as UPDATE? (Either way updating or altering your'e changing the original so what would be the difference between the two? there shouldn't be....)

Reply

miCRoSCoPiC^eaRthLinG
Yep - the INSERT and UPDATE syntax is almost same in any SQL Compliant Database...

Chesso: UPDATE and ALTER have diametrically opposite functions - though both names suggest some sort of updating mechanism... UPDATE is used to modify the DATA stored inside a table, whereas ALTER is used to modify the STRUCTURE of the table itself.

Your usual UPDATE syntax (for MySQL) would be:
SQL
UPDATE tableName SET Field1 = 'newvalue1', Field2 = 'newvalue2', ...;


ALTER, as shown by Hercco allows you to modify the Column names as well as their data types in a particular table... Say in the above table, Field1 was VARCHAR and Field2 was DOUBLE... I want to swap the data types and change the name of Field2 to Field3
SQL
ALTER TABLE tableName CHANGE Field1 Field1 DOUBLE;
ALTER TABLE tableName CHANGE Field2 Field3 VARCHAR(x);

Reply

Chesso
Ahhh so one changes the data stored and the other just changes the type of data stored.

Reply

yordan
Yes, in all SQL RDBMS the syntax is very similar.
CREATE TABLE to create a table
ALTER TABLE to change the table structure
INSERT INTO table to add rows
etc...
Very few differences between Oracle, Ingres, Informix, Mysql, PostGre.
Of course, things are easier if you use integrated scripts like the ones in cpanel, but sometimes you have to understand basics, or at least know the terminology.

Reply

vhortex
QUOTE(nightfox @ Jun 3 2006, 07:08 AM) *

Thanks!! I'll look into all of that. It does look like what I'm after. I use MySQL, not Oracle. But thanks again!!

[N]F


Oracle's SQL is the same as mySQL with just some addons and optiomations..
on the other hand, for a small scale bussiness which need an Oracle functionality,
mySQL 5 is a nice thing to start with..

As long as it uses SQL and a compliant, the database controls are the same..

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Pages: 1, 2
Recent Queries:-
  1. swap tables in sql - 0.67 hr back. (3)
  2. updating 2 fields in sql - 181.43 hr back. (1)
  3. oracle update syntax varchar - 183.41 hr back. (1)
  4. oracle update syntax - 275.57 hr back. (1)
  5. database quary tables in vb - 305.66 hr back. (2)
  6. exact syntax on how to update in database - 451.45 hr back. (1)
Similar Topics

Keywords : updating, databases, tables

  1. Mysql Multiple Tables
    (1)
  2. Databases
    (2)
    How do you access databases?Even though i don't have a hosting account yet i want to think
    ahead. Please help thx, romeo123....
  3. Free Graphical Tools For Databases
    (7)
    There are a lot of different free software in Internet, but I have found only couple of free
    graphical tools for database adminiatration. On another hand, MySQL is free for non commercial
    usage. That's way it will be nice to have any good free GUI for this database. I remember the
    time, when one of MySQL-Front versions was for free, but now it is opened only for testing period.
    There is also free version of Toad, which is not full Toad, but it looks also very well - However, I
    am not going to use Oracle (wchich is quite expensive commercial tool) on my desktop. The....
  4. Mysql Problem
    Linking tables (1)
    Hello guys, I'm making a PHP/MySQL site for a friend of mine who plays an online game where you
    can create towns, add buildings to them and upgrade them to a newer level. I've offered to make
    him a small site where he can input his data into a database and keep track of his towns, buildings
    and levels. I'll show you my database design and then explain what i want to do. Table: towns
    field 1: TownID (primary key, auto-increment) field 2: TownName field 3: TownType field 4: Town
    Description Table: buildings field 1: BuildingID (primary key, auto-incremen....
  5. Script Tables On Sql Server Compact
    (0)
    So I have an application that's using SQL Server Compact Edition 2005. I need to export the
    table schema to a file of SQL statements, containing only the schema...no data, no rows, just the
    tables, indexes, and constraints. Now, when using SQL 2000/2005 I just use the script table as...
    feature to do exactly this, but because SQL server Compact Edition doesn't have the support for
    it, I can't do this. The tables in SQL Server Compact *do* have the information_schema views
    though, so I was wondering if anyone knows of any tools that can read these views and....
  6. All About Databases
    Info, for you! (3)
    QUOTE Hi, I noticed there were a lot of questions in all of the database topics, so i went
    around the internet using different sources, and have some information that will answer your
    questions and help you understand databases. I hope this helps, and if you have any other questions
    which arent answered below, please send a message asking. Thankyou. In computing, a database can be
    defined as a structured collection of records or data that is stored in a computer so that a program
    can consult it to answer queries. The records retrieved in answer to queries become i....
  7. Examining Databases At A Whole Glance
    SQL-92 specification (7)
    Most of us using databases or doing data minings are not aware of SQL-92 specification seemingly
    these days. SQL-92 specifiaction is the SQL database query language standard. Oracle,mysql
    postgresql,mssql and DB2 - most widely recognized SQL database programs - are all closely related to
    SQL-92 specification for the use of query nevertheless how they implemented SQL-92 specification
    features inside in the program. Implementation of SQL-92 specification features are applied in the
    order of Oracle, postgresql and mysql. These databases might have specific database query....
  8. How Do You Make Large Databases?
    (14)
    In a game I'm working on, I would like to have a database of actors/actresses. I'm not sure
    exactly how to do this. I'm pretty sure with the hosting here, I can only have 99 databases.
    I'm a little lost as to how to make it. Can all the actors/actresses be put on one database
    with the specific things I want to include (i.e. how well the do in each genre)? I'm new to
    Mysql and just need some help as to where to start.....
  9. (help With Sql And Php)retrive Datas From Realted Tables And Display Them!
    Please help me to diplay datas by combining 3 tables! (4)
    Hi all.. Please help me to write the SQL Query for the following requirement! Im having 3
    MySQL tables Sales_users Sales_products Sales_details 1st Table (Sales_users) contains unique
    userID and username for the users! 2nd Table (Sales_products) Contains unique Product ID,
    product Name and Product Description! 3rd Table (Sales_details) contacins unique Sales ID,
    Product ID (Foreign Key), FromUser (Foreign Key) and ToUser (Foreign Key) Sales_users
    User_id name 1 ....
  10. Ms Databases
    (6)
    Hello, I can make my own MS Access database, but can anyone tell me how to make a password gate
    that checks the user info with the database? Olie122333 /biggrin.gif"
    style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" />....
  11. Can You Make Your Own MySQL Databases?
    Im an idoit (7)
    Can you make your own MySQL database or do they have to be bought or found from a free site i really
    need help on this guys please reply or send me a PM when you have the time because i need so much
    help with this atm /smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif"
    /> thankyou very much regards Morex Gaming owner Jarvis....
  12. Copy Databases In phpMyAdmin
    (3)
    i have just got hosting here on astahost and i have to copy my databases from my old server... is
    there an easy way of doing this? in phpmyadmin? thanx in advance you know lol /wink.gif"
    style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" /> ....
  13. How To Setup SMF Databases?
    (4)
    does anyone know how to set up a database for a SMF forum.....
  14. Linking Two Tables
    (12)
    I have two tables in a database. userid and usercredits In userid I have all the fields that
    identify the user (name, address etc.) In my usercredits table I have the following fields: IDNUM
    ProgramName Camp# CompletionDate Amount DatePmtSent PmtMethod Comments creditID What I would like
    to understand about my table structure, is how do I associate my credits tothe correct user. If I
    have done this correctly, there is also a field in the first table that is called IDNUM where each
    user has a unique number to identify who they are. When someone is logged into the ....
  15. MySQL, Multiple Tables
    (24)
    Ok, I'm coding a project which is a leap than what I'd normally do. Before, I've always
    learned ONE table... put EVERYTHING in one database table. I'm making a profile system so there
    needs to be at least two tables: 1 for users, 1 for content. My problem is, how do I link the two
    together? I could probably figure this out faster if someone explained and posted sample SQL code
    that shows how the two are linked together. Thanks!! F....
  16. What Is A Database How Do I Use One?
    : Information about Databases and how to get use them efficiently (7)
    Hello All Let's start off by talking about what a database is and how it would be efficient
    in using it. It wasn't until about a year and half ago now that I was first introduced to this
    new age of Database. I discovered a lot of neat things and even learned about databases the very
    long way. A database is exactly how it sounds its data that has a base. The base being the place
    where you store all your data. If you have ever been to a library perhaps you have used the Index to
    search for an author, this is a database of authors. Ever seen a rolodex on someo....
  17. User Priveileges Vs. Tables Vs Rows
    which method is best for accounts/logins (1)
    I want to know which is the most efficient way to create accounts and logins. I have trouble
    deciding which is the better of the three: - User Priveileges - TABLES - Rows....
  18. Creating Tables In MySQL On Home Comp
    (8)
    Hi, I've tried seraching for a bit, but I couldn't find an answer to my questions.
    Recently I've succesfully installed Apache on my Windows XP Machine, along with PHP and mySQL. I
    need a database on my computer for testing purposes. I've enables mySQL in PHP, and both seems
    to be working fine. I can connect to the database, but how do I edit the database? E.g., edit rows
    or modify columns. I would much rather stay away from using the command-line stuff. I'm looking
    for a GUI Query program that I can use, but I have no clue which one to choose. It ....
  19. Combining Databases
    Please help before I mess up! (4)
    I am intergrading this Private Messaging system into my website so that my members can login and
    access their PMs through the seprate PM software without loging in twice and registering twice since
    if I left it as is, that is what they would have to do... All I really need is 1 single table to be
    combined without damaging my few member's accounts (they are all friends, but I don't want
    to tell them that I was playing with the database and lost your account information...
    /rolleyes.gif' border='0' style='vertical-align:middle' alt='rolleyes.gif' /> ) Since I d....
  20. Unexpected Database Crashes
    sometimes my astahost databases are down (0)
    Sometimes some of my astahost databases are down. After a couple of hours or a couple of day they
    are up again. Sometimes all of them are down at the same time, sometimes some of them are up and the
    other ones are down. The symptom is that when I connect to the forum I have an error message, saying
    "Parse error: parse error, unexpected '\"', expecting ',' or ';' in
    /home/../../.../../index.php on line 25" It's not an error in my phpbb because it used to work
    correctly. So, what happends ? I suppose that the databases crash if the astahost....
  21. Creating Databases
    from programs (4)
    I jsut went throught PC magazine today and i found out that you can actually create a database using
    Microsoft Access and Excel. And computers and servers online can actually use these databases and
    conduct queries with them. I've always though of databases as MYSQL, Microsoft SQL server and so
    on. So it is possible to store data to a Microsoft Access database and manipulate it online?....
  22. Migrating Databases
    Migrating from MSSQL Server to MySQL (2)
    How to migrate my database from SQL Server to MySQL?....
  23. Remote Databases
    How to allow remote connections? (4)
    I am currently in a big-problem. I am trying to use a MySQL database on another host, and I am
    hosting my forums, on another host, and I am trying to install the forums but the error that comes,
    says that the remote connection canot be allowed. Can anyone help me on how to resolve this issue
    and proceed further, or should I just wait for astahost.com to get an account? All suggestions
    welcome! /biggrin.gif' border='0' style='vertical-align:middle' alt='biggrin.gif' /> ....
  24. Hosting A Server On Database
    I'm a total noob at databases (6)
    Well this might be in the wrong place or I might have no clue what im talking about but I heard
    something. Is it possible to host like a .exe server such as a macromedia multiuser server on a
    database such as MySQL or any other databases? I have a friend that said he did it but I think he is
    lying. Thanks in advance!....
  25. Recover Tables From A MySQL .frm File
    (8)
    I have a couple of .frm files with no corresponding data or index files. Is it possible to recover
    the table structure (field names, types, sizes, rows,col, etc) from these files? The table type is
    innodb....
  26. Need Advice On Creating Online Music Database
    ps - dont know anything about databases! (6)
    I need to create a database of around 1000 music albums that I can put on my site, with the ability
    to search the database according to several different criteria. Being a complete and total NOOB to
    the world of databases, can anyone point me in the direction of some software that will let me
    create a good-looking and functional database, but that isn't too complicated for me to
    use?! Sounds like a tall order I know, be grateful if anyone can help though. Thanks!
    Topic edited to reflect content better. ....
  27. The Best Database
    databases (41)
    te best database for my is sql server yukon for you?....
  28. Free Databases
    mysql,postgresql,SAPDB,sybase,DB2 (14)
    this website offers Database hosting for free. Jus signup and u get u r own database .. it supports
    mysql, postgresql, sapdb, sybase, db2 CODE http://freesql.org from the webpage QUOTE
    This service is, and will remain, totally free. I have receive hundreds of Thank you emails from
    all over the world telling me that having this service available has allowed them to practice and
    learn without the burden of having to run their own server. ....
  29. Generating Many Tables
    (2)
    I have a database that will contain 43 tables (among others). For these particular tables, they will
    each contain the same type of information, each representing a particular week in the NASCAR season.
    I used the following script to create one table: DROP TABLE IF EXISTS gulfOwnerDriversWeek1;
    CREATE TABLE gulfOwnerDriversWeek1 ( ownerIndex int primary key, driverIndex1 int, driverIndex2 int,
    driverIndex3 int, driverIndex4 int ); This table represents a draft sheet for one particular week
    (Week 1) for a particular team. My first question is, should try to put all week....
  30. Selection From Multiple Tables
    (0)
    I am in the middle of creating a little forums system, and all so far is going quite well. However I
    have come across a small problem; PHP:
    --------------------------------------------------------------------------------
    $gather_forums_qry = "SELECT a.frm_id, a.frm_name, a.frm_description,
    count(distinct(b.fth_id)) ThreadCount,
    count(distinct(c.fpt_id)) PostCount, a.frm_enabled,
    IF( IFNULL( MAX( b.fth_dateposted), 0) > IFNULL( MAX( c.fpt_d....

    1. Looking for updating, databases, tables

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for updating, databases, tables
advertisement




Updating A Database's Tables



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE