i have a table in access and i would like to get the SQL string from it that will generate the table like:
CREATE TABLE example (
id INT,
data VARCHAR(100)
);
is there any way to do this?
I don't believe there is a built in way. You will have to use a third party tool to convert the schema:
DBWScript
MDBScript
To run a VB Script to convert the tables there is on here:
Table Creation DDL from Microsoft Access
If you are talking about a generic method that will work on any Access table I don't know of any way to get a SQL CREATE table statement directly. I suspect there are too many features in Access (drop down values for fields, input masks, etc.) that don't translate well to SQL.
Access does have the ability to export the table directly to SQL Server however. You could try to push the table to SQL Server and then generate the CREATE statement from that.
If you're trying to port this to SQL server or the like, I think you'll have to build the scripts by hand.
You could always use the SQL server import wizard (or the export to SQL from Access) to move it over, then create the scripts in SQL server.
Don't forget, you can usually get SQL Express for free, so that's a way to do things.
May be exporting the tables to XML/XSD? It's not DDL but you have the schema in a file that you can import using other tools.
More or less as you have it:
CREATE TABLE example (
id INT,
data text(100)
);
You may wish to check out DAO data types: http://allenbrowne.com/ser-49.html
Related
I have a database called AQOA_Core with huge amount of data.
I have a newly created database called AQOA_Core1 which is basically empty. I want to write a query to duplicate AQOA_Core to AQOA_Core1 without the data. I guess to be precise I want to create a skeleton of the primary database into the secondary database.
PS: I use Toad for my database operations.
You can use SQL Server Script Wizard for scripting database objects. You can exclude data, and select the database object types you want to include in your script
Please check the SQL Server guide I referenced above,
I hope it helps you
I have a few large tables in a oracle DB (lots of columns and data types) that I need to move to another oracle database (say from my DEV region to UAT region). Is there anyway I can get sql developer or sql plus to output a create table statement that is exactly the structure of the existing table?
thanks
If you want to get it through SQL statement then you can try the below query
SELECT dbms_metadata.get_ddl('TABLE', 'Your_Table_Name') FROM dual;
See DBMS_METADATA for more information.
You can generate the script using Toad software as well (In case you have Toad installed)
If you are making use of the SQL Developer you can right click the table that you want to generate a script for.
From there select Quick DDL and then click on Save To File. This will then generate the create table script to an external sql file. You can do this for multiple tables as well by selecting more than one table at a time.
Hope this helps!!
Another option is to create a database link between the two schemas and then do a
create table table_name AS SELECT * from table_name#original_server
I'm using Oracle PL/SQL developer. I have two databases live and dummy.
I have been using the dummy database for development and now i need to add all the new tables and data into the live database without effecting the data currently stored in it.
I also need to copy over all the new sequences and triggers.
I've tried exporting a table but had no luck and using the SQL view i only get the SQL for the creation of the data and not the data it contains.
I also found this SQL code
COPY FROM test#DUMMY - CREATE test -USING SELECT * FROM test;
But it asks me for a name and password of which I dont know and then fails after 3 attempts. It then goes on to say there is a syntax error as well.
I'm still fairly new to using Oracle and any help would be appreciated.
You can do that using datapump.
or if you want to copy from schema to schema
create table shecma2.old_table
as
select * from schema1.old_table
or using oracle sql developer - here is link.
Try:
CREATE TABLE NEWTABLE AS SELECT * FROM OLDTABLE;
I have read only permission on a SQL Server 2005 database, and I'm looking to get a table schema locally to work with. With my current access it won't let me right click on the table and choose 'Create Table' to get the script for this.
Is there a way to generate the create table script from a select statement or by some other mechanism?
Thank you!
You could create a linked server on your local machine. Then, you can use select ... into to copy the table, including data:
select *
into NewTableName
from [LinkedServerName].[DatabaseName].dbo.TableName
This will not copy indexes or constraints. To exclude the data, use select top 0 *.
It's a bit long but the script in Script Table Definitions using TSQL could be addapted to work without needing to create the stored procedure mentioned.
I am assuming you are working with SQL Server 2005
When I right click on the database I want to export data from, I only get to select a single table or view, rather than being able to export all of the data. Is there a way to export all of the data?
If this is not possible, could you advise on how I could do the following:
I have two databases, with the same table names, but one has more data than the other
They both have different database names (Table names are identical)
They are both on different servers
I need to get all of the additional data from the larger database, into the smaller database.
Both are MS SQL databases
Being that both are MS SQL Servers, on different hosts... why bother with CSV when you can setup a Linked Server instance so you can access one instance from the other via a SQL statement?
Make sure you have a valid user on the instance you want to retrieve data from - it must have access to the table(s)
Create the Linked Server instance
Reference the name in queries using four name syntax:
INSERT INTO db1.dbo.SmallerTable
SELECT *
FROM linked_server.db.dbo.LargerTable lt
WHERE NOT EXISTS(SELECT NULL
FROM db1.dbo.SmallerTable st
WHERE st.col = lt.col)
Replace WHERE st.col = lt.col with whatever criteria you consider to be duplicate values between the two tables.
There is also a very good tool by Redgate software that syncs data between two databases.
I've also used SQL scripter before to generate a SQL file with insert statements that you can run on the other database to insert the data.
If you right-click on the database, under the Tasks menu, you can use the Generate Scripts option to produce SQL scripts for all the tables and data. See this blog post for details. If you want to sync the second database with the first, then you're better off using something like Redgate as suggested in mpenrow's answer.