Original: PowerDesigner 16.5 tips for reverse engineering from SQL Server 2012: Unable to List tables issuesShenzhen team to develop a system in the North China side to push customers, in a patch, due to changes in the data dictionary, but the Shenzhen team did not give the database update script, only to the new versi
The requirement is that there are more than 2000 tables under the Stock library in SQL Server. Each table is required to delete one of today's error data.First you have to get the names of all the tables, the code is as follows:Select from Where XType='U'and'inserthistory '
1, the original database of the project is SQL Server, now you need to import the original database into Oracle. Now you want to use Java code to get all the table names, whether there is data in the table, and the table data details.2. Open SQL Server, use the command to ge
Label: --/1th Step ********** Remove foreign KEY constraints for all tables *************************/
DECLAREC1cursor for
Select 'ALTER TABLE ['+ object_name(parent_obj)+ '] Drop constraint ['+Name+']; '
fromsysobjectswhereXtype= 'F'
OpenC1Declare @c1 varchar(8000)
Fetch Next fromC1 into @c1
while(@ @fetch_status=0)
begin
exec(@c1)
Fetch Next fromC1 into @c1
End
CloseC1deallocateC1--/2nd Step ******
Display information for all tables or views in a database in a SQL ServerThe difference between SQL Server 2000 and 2005 is in the Red Word sectionThe following statement takes all table information and replaces the green bold wor
Tags: column int where for main color CTS SQL refDirectly on the code: 1 SELECTOsub.name as [child table name] ,
2Fk.name as [FOREIGN Key Name] ,
3Subcol.name as [child table column name] ,
4Omain.name as [Primary Table name] ,
5Maincol.name as [primary table column name]
6 fromSys.foreign_keys FK7 JOINSys.all_objects osub on(fk.parent_object_id=Osub.object_id )
8 JOINSys.all_objects Omain on(fk.referenced_object_id=Omain.object_id )
Label:if exists (select * from sysobjects where type= ' P ' and Name=n ' P_deletealldata ')drop procedure P_deletealldataGoCREATE PROCEDURE P_deletealldataAsEXEC sp_msforeachtable ' ALTER TABLE? NOCHECK CONSTRAINT All '--disable constraintEXEC sp_msforeachtable ' ALTER TABLE? DISABLE TRIGGER All '--disable triggerEXEC sp_msforeachtable ' delete from? '--delete data from
CREATE PROCEDURE sp_deletealldataasexec sp_msforeachtable ' ALTER TABLE? NOCHECK CONSTRAINT All '--disable the constrained exec sp_msforeachtable ' ALTER TABLE? DISABLE TRIGGER All '--disable trigger exec sp_msforeachtable ' DELETE from? ' --Clear data exec sp_msforeachtable ' ALTER TABLE? CHECK CONSTRAINT All '--restore constraint exec sp_msforeachtable ' ALTER
Shenzhen team to develop a system in the North China side to push customers, in a patch, due to changes in the data dictionary, but the Shenzhen team did not give the database update script, only to the new version of the database creation script, in order to ensure that the client system has no loss of data, Can only find a way to do it: using PowerDesigner to reverse the new version of the database, apply this model to the existing database, the PowerDesigner will compare two versions of the d
Expert answersBy querying three system tables in any database, you can obtain the default values of each field in each table. The following is the core query. It returns the default value allocated to each user table in the current database. This query is compatible with SQL 2000 and SQL 2005. Quote:Copy codeThe Code is as follows:Select so. name as "Table Name
Topics: Listing code for all libraries on SQL Server
First: dbo permissions list all databases on the server
Copy Code code as follows:
Dim SRV
Dim Objdb
Set srv = Server.CreateObject ("SQLDMO.")
Expert answers
By querying three system tables in any database, you can obtain the default values of each field in each table. The following is the core query. It returns the default value allocated to each user table in the current database. This query is compatible with SQL 2000 and SQL 2005.
Quote:
CopyCode The Code is as follows: Select so. Name as "table n
sysobjectswhere xtype = ' u 'Open C2DECLARE @c2 varchar (8000)FETCH NEXT from C2 to @c2while (@ @fetch_status =0)BeginEXEC (@c2)FETCH NEXT from C2 to @c2EndClose C2DEALLOCATE C2--3. Enabling FOREIGN KEY constraintsDECLARE C1 Cursor FORSelect ' ALTER TABLE [' + object_name (parent_obj) + '] Check constraint [' +name+ ']; ‘From sysobjectswhere xtype = ' F 'Open C1DECLARE @c1 varchar (8000)FETCH NEXT from C1 to @c1while (@ @fetch_status =0)BeginEXEC (@c1)FETCH NEXT from C1 to @c1EndClose C1DEALLOC
How does I list all tables/indices contained in an SQLite database
If you is running the sqlite3 command-line Access program you can type ". Tables" To get a list of all T Ables. Or you can type '. Schema' to see the complete
when the user is disconnected from the Microsoft SQL Server instance. The name of the global temporary table starts with a mathematical sign (#). After being created, it is visible to all users. All users who reference this table are deleted when they are disconnected from SQL
Tags: div requires code foreign key const logs open span objectDelete database all tables and all stored procedure SQL statements at once Transferring database data today requires emptying the database's original tables and stored procedures.To delete
From http://hi.baidu.com/yocnnzrmilceijr/item/d1d928f8e8cc73ea1b111f07
Delete all tables:
If table deletion fails due to foreign key constraints, delete all constraints first:
--/Step 2 *********** Delete the foreign key constraints of all tables ******************* **
This article introduces how to obtain the names of all tables in a database and the names of all fields in a table. For more information, see.
This article introduces how to obtain the names of all tables in a database and the names of a
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.