473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

equivalent of table.column%TYPE

-
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 2631
-
- 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
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),...
0
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),...
4
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
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...
4
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...
1
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...
13
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...
8
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...
3
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#"...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.