How to basically copy tables with new names rather than create similar tables from similar manual input.

I have a table that I am basically reduplicating a couple of times for each part of this database that I want to create.

Each table basically has the same data: The tables will be called motherTable, fatherTable, sonTable, daughterTable and so on.

I am pretty much using the following in each column: UserID, MotherID(or FatherID or SonID, etc., etc. and so on for each unique table), FirstName, LastName, MiddleName, BirthPlace, Photo, Age.

I don't see an option to copy a table and just modify the second ID part and rename that table accordingly.

How can I make this an easier way of creating these similar tables without retyping all these columns over and over again?

Thanks in advance.
 

0
foolios
5/26/2007 10:34:49 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

4 Replies
780 Views

Similar Articles

[PageSpeed] 46
Get it on Google Play
Get it on Apple App Store

In SQL Server
select * into newtable from existingtable 
To copy only the structure
select top 0 * into newtable from existingtable 


In Oracle
Create Table newtable as select * from existingtable
To copy only the structure
Create Table newtable as select * from existingtable where 1=2
 

Regards,
Prashant


Dont forget to click "Mark as Answer" on the post that helped you.
0
Prashant
5/27/2007 3:15:24 AM

Sorry, SQL 

 I was thinking of putting all the data into one table, but the problem I ran into was that if I listed more than one family member for a column. I couldn't?
For example, if I decided to list my cousin. But I've got 3 cousins, so now I would have to put my same info 3 times into the table. So I was thinking that that would be majorly denormalized.
So now I'm kinda stuck again about this aspect now that you mention it. How do I do this the right way?

So for example, two tables:
UserTable:
UserID, Username, Password, FirstName, Lastname, Age, Email

BrotherTable:
UserID, FirstName,  LastName, Age, Photo

Now if I combined them.
Table:
UserID, Username, Password, FirstName, Lastname, Age, Email, BrotherFN, BrotherLN, BrosAge, Photo, BroPhoto

But then I have 3 brothers. That just makes this a mess and so confusing.

Serious problem...

0
foolios
5/27/2007 6:09:45 AM

Going by the type of data you have mentioned, it makes sense to have a table called "RELATIVES" that has UserID as the foreign key referencing "USERTABLE".

Your "RELATIVES" table could have a column called Relationship (brother, sister, cousin etc)

This way you can have as many relatives you want for each user (1 to many relationship between USERTABLE and RELATIVES) 

 


Regards,
Prashant


Dont forget to click "Mark as Answer" on the post that helped you.
0
Prashant
5/27/2007 10:17:07 AM

 That looks interesting. 1 is related to 2, how? He's a brother.
Hmm. Ok, lets see. I add some information about a user. I add that he is related to someone. But I'm having a difficulty with that because doesn't that other person have to exist as a user as well. I mean, I want a person to add info about themselves and then also about family members related to them. So as I'm thinking this, I guess I would have to create all these people at the same time then wouldn't I? Err I mean, that user would have to fill out all the details of these other people at once. But maybe not.
I am having a problem conceptualizing this.

I add Joe Morgan as a user. But now Joe Morgan has to also add Jessica Morgan as a user as well so that he can fulfill this relationship table. Ok, so maybe that's not so bad. There doesn't appear to be any problem with a user creating users. Well, then again, yes there would be log-in problems.

Ok, am I seeing these difficulties right? Can someone run me through a cycle of how I could manage this?

I would appreciate that, I am really new to this kind of thinking. I want to understand this relational database technology. Thus why I want to create this database for a website as practice.

Thanks in advance.
P.S. It's late and I am tired too. I am sure you are as well as you've probably come to this board after work and all the chores are done and just before hitting the sack. I hope I am not making a fool out of myself. If I am, I apologize; maybe when I get up in the morn I will have better realizations of what I am trying to do with this.

0
foolios
5/28/2007 5:15:31 AM
Reply:

Similar Artilces:

How do I create a text table similar to a word table
I am creating a multiple page document which contains a 7 page questionaire.  The left hand side has the questions, each in its own box, the right hand side is just a blank box. The start of the table is on the first page but varies according to the variable text printed above it.  Hence the number of questions which print on the first page varies.  Consequent pages also end up with different number of questions as they vary in length and complexity. What I need to happen is when the page breaks for the left and right boxes to to be complete and line up. 2 methosd have been...

how to create a new sql table from xml table through coding
I have a xml tableProgramatically I have to convert the data to sql table and show the data in the grid view from the sql tableall I have to do by coding onlycan it be possible  Hi, As far as I know Torque can generate SQL source from an XML schema describing a database structure: http://db.apache.org/torque/releases/torque-3.1.1/generator/ However you need to do that throught coding which is not as simple as it sounds. You may have to transform xml schema to sql schema manually or use xslt. Or you can load xml schema into dataset and create database schema from dataset. Hop...

How can i copy a data from a table to another similar table automatically
 I trying to figure out how to copy a inserted data from a table to another table automatically. Can anyone please help me with the coding.. Thanks you You can use database triggers to automatically store the inserted data in a history table.See my previous post to get you started: http://forums.asp.net/t/1274240.aspx If this post was useful to you, please mark it as answer. Thank you! Hello Vynel: You can create a stored procedure like the following... CREATE PROCEDURE spASSELECT  *INTO BackUpTableFROM OriginalTable  Notice that select into will create a new ...

Reverse Engineer created copies of table (table:1, table:2)... How do I merge them back into 1 table?
PowerDesigner 12.1 I just reverse-engineered about 20 tables from our database, and it took one of my key tables and created two copies ("TableName : 1" and "TableName : 2"). I'm sure the engine was trying to make the diagram easier for it to auto-layout, but I want all the FKs and such from one table). How do I merge them back into just one table? Thanks, Jason Jason Vogel wrote: > PowerDesigner 12.1 > > I just reverse-engineered about 20 tables from our database, and it took > one of my key tables and created two copies ("Tabl...

Creating a table with similar attributes to another table in Adaptive Server Anywhere
In DB2 we can excute the CREATE TABLE LIKE or use the SELECT * INTO newtablename clauses. Does anyone know of a similar one liner that could be used in adaptive server anywhere. If there is one please let me know. If not, then is ASA going to have such a function in the coming future. Thanks In Advance. You might want to post this over in the sybase.public.sqlanywhere sections. On Fri, 31 Mar 2000 09:46:56 -0800, in powersoft.public.powerbuilder.database Derrick Chan <dpccon@earthlink.net> wrote: >In DB2 we can excute the CREATE TABLE LIKE or use the SELEC...

C# method using ado.net to create an html table with just the db table name
 I was wondering whether there was a simple way using ADO.NET in C# to have a method that has the following header: public static String viewTable(String tablename) that outputs the data either in: <table> <tr> <th>Headings</th> // Repeat for each column in table </tr> <tr> <td>Values</td> // Repeat for each record (and for each column) in table </tr> </table> OR <table> <tr> // Repeat these 4 lines for each column & display values for the first record <td>Heading...

Create new Table from existing table
Hi I'm trying to Create a new Table from existing table in Q/Analyzer. I figured it would be something like this: CREATE TABLE newTable AS(SELECT * FROM OldTable); but i keep getting Server: Msg 156, Level 15, State 1, Line 1Incorrect syntax near the keyword 'AS'. also.. is there another method of doing this, something like INSERT INTO newTable(SELECT * FROM OldTable); and it creates the table ( newTable ) for u if it doenst already exist?? Cheers!!! im using sql2000 You can try this one: SELECT * INTO newTable FROM OldTableLimno The easiest method to copy ...

Creating new Tables/View in a SQL Database using VS.NET 2k3
Using server explorer in VS.NET, I can not create new tables or even views for a SQL database for exemple the Northwind DB. When I right click the Tables node I don't have anything labled Create new table, even for views.  Can someone point me how can switch to the design view in VS.NET?  In a Step by Step manner, please.  Thanks.I have been trying to change the world for years, but they just won't give me the source code! any help please?I have been trying to change the world for years, but they just won't give me the source code!...

Copy table structure to a new table
Hello everyone, I have a local MSSQL server (I guess it's called MSDE), with some tables that I would like to use as a template for a set of new tables. I would simply like a Stored Procedure that takes these 3 tables, makes a copy of their structure (not data, since they will be empty), and name them by using a parameter given to the SP. I have made something that I thought would work, but after testing it a bit more, it seems to forget default values for the fields, which is of course not good enough :). I hope that someone can tell me how to duplicate t...

how to join existing table with table created by "create existing table"
"create existing table" can help to create a table which is linked to a sp select selection. but can this table be join to other physical tables? Yes, proxy tables can be used in joins. -bret ymho wrote: > "create existing table" can help to create a table which is > linked to a sp select selection. > but can this table be join to other physical tables? but i cant, pls refer my example below: create procedure po_t1 (@p1 char(8) ) as begin select ret_date=convert(datetime,@p1) end go CREATE EXISTING TABLE t1 (ret_out1 datetime not null, ...

Create table with user specified table name
ok suppose i want to  create a table with a user specified name...... how should i replace the name with the variable name="table1"         Dim condb string .......         Dim cmdDB2 As SqlCommand               Dim  name as string=("table1")        Dim selkta As String = "CREATE TABLE name(no int,quest text,op1 text)"             cmdDB2 =...

How to create a table with copying everything from an existing table
Hi, I would like to create a table that is identical to an existing table (table definitions, structures, and data itself). In Oracle, the following command will do the work: create table new_table as select * from existing_table; But in Sybase, it seems there is no such command to do the job. Is there any way to do it? Thanks for your help. There is command: select * into new_table from existing_table This will work.....go ahead Xiaobing Suo <xsuo@imake.com> wrote in message news:39BE3510.480CEEF1@imake.com... > Hi, > > I would like to create a table t...

Creating Table to Connect to a SQL Server Table
Hello everyone! I need to create some tables when my web page is been created these tables are in a SQL server database. I found a sample code to do that using a Access table can someone please send me or point me out to some link where I can learn how to do that. Tia Charles   -------------- Sample code I got from the net ----- private void buildGrid() { string sql; sql = "SELECT * FROM Products"; System.Data.OleDb.OleDbDataAdapter daSrc = new System.Data.OleDb.OleDbDataAdapter (sql, dbCon); DataTable oTable1 = new DataTable("Products"); daSrc.Fill(oTable1); sql = "S...

Create new Table
Hi, I create new database access with Web Matrix Wizard (microsoft access is not installed in my pc) and later I create new table with Data Wizard "Create new Table" but later inserted table name "prova", Web Matrix Wizard response: Error adding table The Error Description is in Italian: Il tipo di valore utilizzato dall'applicazione non è valido per l'operazione corrente. Help! I receive an error which I believe is the same. The message in English, in case it is useful to anyone, is: "Application uses a value of the wrong type for the curre...

Web resources about - How to basically copy tables with new names rather than create similar tables from similar manual input. - asp.net.sql-datasource

Basically Me... (@the_4th_floor) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

Paul Krugman On Rand Paul Candidacy: There Basically Aren't Any Libertarians (2015) - YouTube
Economist Paul Krugman states that there basically aren't any Libertarians (2015). To call Paul Krugman stupid, would be an insult to stupidity. ...

Organic fruit and vegies: are they basically a waste of money?
Buying organic vegies at the supermarket is basically a waste of money.

Why almond milk is basically a scam
Almonds make up only 2% of the drink in some brands.

Hipster style: is this the end, basically?
A keep-it-simple trend endangers ironic beards and complicated coffee.

'Without them basically my son wouldn't be here': group form human chain to rescue drowning boy
Desperate beachgoers formed a human chain to battle "treacherous and dumping" waves to save a boy from drowning.

Captain America: Civil War is basically Avengers but with Ant-Man
The Hulk is probably sad right now since he's one of the only Avengers not in Captain America: Civil War.

Andrew Embley: 'I basically didn't stop drinking'
Retiring West Coast midfielder Andrew Embley says he had to make a lot changes to become a player who made his mark in the Eagles big games. ...

Rumer Willis Is Basically Naked For Fashion Campaign
Rumer Willis' love of cutouts has no limits! Bruce Willis and Demi Moore's eldest daughter posed in a very naked Spring '15 fashion campaign ...

China, U.S. basically complete text negotiation on BIT
China, U.S. basically complete text negotiation on BIT

Resources last updated: 11/26/2015 8:19:12 AM