473,804 Members | 3,200 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

equivalent of table.column%TY PE

-
in oracle there is a '%TYPE' to reference the data type of another
column. is there an equivalent in mysql? thank you.
Jul 23 '05 #1
7 2653
-
- wrote:
in oracle there is a '%TYPE' to reference the data type of another
column. is there an equivalent in mysql? thank you.


anybody? do help...
Jul 23 '05 #2
- wrote:
in oracle there is a '%TYPE' to reference the data type of another
column. is there an equivalent in mysql? thank you.


I'm not sure what you are going to do with it, but the best I can think
of it describe:

http://dev.mysql.com/doc/mysql/en/describe.html
Jul 23 '05 #3
-
Aggro wrote:
I'm not sure what you are going to do with it, but the best I can think
of it describe:

http://dev.mysql.com/doc/mysql/en/describe.html


what i want to do is to refer to the column's data type.

CREATE TABLE country
(
code CHAR(2)....
....
)

CREATE TABLE user
(
..
country_code country%TYPE
..
)

in this case the code's data type is permanently 2 char long but for
other fields, it would be easier if i just put '...%TYPE' so that if the
original field changes, i do not have to change the other fields that
refer to it.

Jul 23 '05 #4
- wrote:
in this case the code's data type is permanently 2 char long but for
other fields, it would be easier if i just put '...%TYPE' so that if the
original field changes, i do not have to change the other fields that
refer to it.


There's nothing like that which I would know.

I got only something like 3 years of work experience in building
databases, but I have never even thought that I could have a problem
like that. Do you really change the column types in your database so
often that you really need to worry about this? Do you really have so
many references to other column types that you couldn't do that manually
if you need to change it?

If I have a reference to other table, I always use int unsigned -type. I
have never had a need to change it. Normal columns that haven't been a
reference to anywhere, sometimes need the change, but in those cases the
%TYPE wouldn't help.
Jul 23 '05 #5
-
Aggro wrote:
If I have a reference to other table, I always use int unsigned -type.


can you rephrase this? i don't get what you mean. thanks.
Jul 23 '05 #6
- wrote:
Aggro wrote:
If I have a reference to other table, I always use int unsigned -type.

can you rephrase this? i don't get what you mean. thanks.


Ok, your example would be this:

CREATE TABLE country
(
id int unsigned primary key;
code CHAR(2);
....
)

CREATE TABLE user
(
..
country_id int unsigned;
..
)

So, now the reference to other table is "int unsigned". And like I said,
I have never had a need to change that reference type to another.
Jul 23 '05 #7
-
Aggro wrote:
Ok, your example would be this:

CREATE TABLE country
(
id int unsigned primary key;
code CHAR(2);
....
)

CREATE TABLE user
(
..
country_id int unsigned;
..
)

So, now the reference to other table is "int unsigned". And like I said,
I have never had a need to change that reference type to another.


in this example where int is used is acceptable. but when the code is
the primary key where there can be two and three character country code
formats (e.g US and USA).

therefore, the master table will have a CHAR(2) or CHAR(3) and referring
tables will need to know the used data type. so, if mysql has a %TYPE,
it would eliminate the need for referring tables to change the data type
each time the master table's type is changed. although the search and
replace function do make life easier.
Jul 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2528
by: Albretch | last post by:
I am trying to insert some textual data belonging to an HTML page into a table column with 'TEXT' as data type mysql's maual _/manual.html#String_types tell you, you may insert up to (2^16 - 1), that is 65535 characters, but I am getting errors when I try to insert a column larger than 236 characters. Initially I thought it might be because I had to escape some characters, but after playing a some scenarios and just inserting a bunch...
0
1329
by: vadnala | last post by:
I am a newbie and struggling to get the correct Column "Type". I really appreciate if someone can shed some light here.. I have a table XXX which has 4 columns with types char(2), varchar(5), int(10) and int(10) respectively. But, when I use the following code, I don't get the correct type from MYSQL_FIELD structure!! int nSuccess = mysql_query ( (MYSQL*)m_hdb, "select * from XXX" );
4
1062
by: Justin | last post by:
Using an SqlDataReader what is the best way to determine if a table column has specified value? Thanks, Justin.
4
6468
by: Ying Lu | last post by:
Hello, Under mysql, we have "desc tablename" to get the detail information about a table. My question is about to get column name, and column type for a specific table under PostgreSQL through JDBC. Assume we have a table named "test". Under PSQL, we can input "\d test" to see the details about table "test" successufully. However, my main purpose is trying to get column name, column name of a table through JDBC.
4
4822
by: joshd | last post by:
can anyone help me figure out why when i run the following stored procedure i get the error: (1460 row(s) affected) Msg 245, Level 16, State 1, Procedure SP_SALESTRENDS, Line 40 Conversion failed when converting the varchar value 'X' to data type int. SP:
1
3193
by: lee1212 | last post by:
Hi I use vb.Net to open an access db for my software and i have one issue that i don't know how to do, I need to change an exsiting Column that might have some records in it from Text(250) to Memo type cuz i need to store some text that its length is more then 250. Is there any way that i can do something like: Alter Table TABLENAME {Alter Column COLUMN1 Memo} and to change the column type from text to memo without delete the records?...
13
7566
by: rupak | last post by:
Hi! I have a multiple selection of checkboxes <input type='checkbox' name='coffee' id='col1' value='Address'/> <input type='checkbox' name='coffee' id='col2' value='Name'/> <input type='checkbox' name='coffee' id='col3' value='ID'/> <input type='checkbox' name='coffee' id='col4' value='UserName'/> <input type='checkbox' name='coffee' id='col5' value='Code'/>
8
6792
by: mguy27 | last post by:
We have about 2 dozen security officers who patrol about 120 buildings. They find defective or unlocked doors and write a "Trouble Report" on the door. This card gets turned in, where I have designed an Access Field and Table to enter the information and store it. They then get emailed to their respective supervisors so the problems can be dealt with. As of right now, we have a big list on the wall of the buildings and their supervisors....
3
3495
by: jagdeep gupta | last post by:
Here i use image in background in table column it does not displays the image but if i apply the same path for img tag in foreground it displays. Here is code: <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10583
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9160
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5654
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.