I need a query to create a table that is an exact replica, but with a different table name and without any data from the original table using an SQL query!
You can try this
SELECT * INTO Table_Copy FROM Table where 1=2
It will create an empty table with the same structure.
Jonathan has this (upvoted), and you should probably go for it because it's more portable. I usually use something like this:
SELECT TOP 0 * INTO [New_Table] FROM [Old_Table]
I think this better expresses what you are doing, but I like Jonathan because "TOP 0" is SQL Server and therefore it is more portable.
MySQL SHOW CREATE TABLE table_name;
CREATE TABLE. , .
http://dev.mysql.com/doc/refman/5.1/en/show-create-table.html
Postgresql:
CREATE TABLE LIKE table_name
http://www.postgresql.org/docs/8.1/static/sql-createtable.html
, - .
SELECT * INTO Table_Copy FROM Table
.
:
CREATE TABLE foo AS SELECT...
select * into newtablename from sourcetablename go truncate newtablename go
, , truncate.
create table <new table name> as select * from <old tale name from which you would like to extract data>
, .
postgres INHERITS LIKE ( )
CREATE TABLE client_new ( LIKE);
CREATE TABLE client_new() INHERITS ()
INHERITS . () , (). LIKE , , . INHERITS, . , .
Source: https://habr.com/ru/post/1712458/More articles:Image loading extjs in TreePanel - javascriptThe Best Strategy for Branching SVN Code and Supporting Links to Visual Studio Projects - .netHe graduated from the first year of study at the university ... What to do in the summer? - javaSAS Error Message (FATAL: Code Generation Error Detected During MISSING Smear Generation) - fatal-errorUse ampersand in CAST in SQL - castingHow to dynamically bind a socket to only one network interface? - c ++How to stop elements in ContextMenuStrip from processing ampersands specifically? - c #объединение двух таблиц с одинаковым столбцом в значение в один - sqlSyncLock on SyncRoot - multithreadingRemoving one item from the trash - c #All Articles