Showing posts with label primary. Show all posts
Showing posts with label primary. Show all posts

Monday, March 19, 2012

Is it possible to "disable" all restrictions on a Ms sql DB?

In meen. primary keys, NOT NULL, IDENTETIES...et.c

I have to do a maunally, one time, building of a database. Sometables has to
stay an some are to be exchanged. The foreignkey inforcemnt ill do for my
self so everything is correct. I just need to be allowed to de thede task
for a while. Is it impossible?

Regards
Anders"Flare" <dct_flare@.hotmail.com> wrote in message news:<3f302ad3$0$24659$edfadb0f@.dread14.news.tele.dk>...
> In meen. primary keys, NOT NULL, IDENTETIES...et.c
> I have to do a maunally, one time, building of a database. Sometables has to
> stay an some are to be exchanged. The foreignkey inforcemnt ill do for my
> self so everything is correct. I just need to be allowed to de thede task
> for a while. Is it impossible?
> Regards
> Anders

You can disable foreign keys, check constraints and triggers with
ALTER TABLE. But you can't disable primary keys, NULL/NOT NULL is
(usually) part of the column definition, and IDENTITY is a column
property, so they can't be enabled/disabled in the same way.

It's not entirely clear from your comments what problems you're having
with the import, so if you can be more specific then perhaps someone
can help.

Simon

Wednesday, March 7, 2012

Is it a good idea to use SQL2005 MDF for audit, exception tracking

I am writing a web application that uses a Teradata database as the primary data source. While Teradata is great as a data warehouse and managing Terabytes of information it doesn't do as well when update or inserting. I was thinking of using a local SQL2005 MDF file to hold a few reference tables and an audit table to collect usage information and exception database to capture any errors.

There could be a few thousand users of the web application but no more than a couple hundred at a time.

I just trying to get some opinions on these technique. I am open to all comments and suggestions.

Thank You

Hi John,

If you're using the SQL Server as the auditing database and exception tracking, I think it will be fine.

Although there will be hundreds of connections to the main app, the exception will not be much and audit data size will not be huge then. Just connect the audit and exception handling module to your SQL Server database, and it will be OK.

HTH. If this does not answer you question, please feel free to mark it as Not Answered and post your reply. Thanks!

|||

Kevin

Thank you. I'm wondering if it is acceptable practice to run SQL Server 2005 express rather than installing a full SQL Server 2005 on the Advanced Server for doing the Audit tracking and exception reporting. The MDF file should never reach the 4GB limit of Express. Thank you again for your answer.

Is it a bug in SQL CE?

Hi!

I use SQL CE with VS.NET. I find the following bug 2th.

The table has an "ID int IDENTITY(0,1) PRIMARY KEY,". That is my row identity.

I add rows to the table, then I realized that the ID order not in the general order (from 0 to ........)

For example: 6,7,8,0,1,2,3,4,5.

Of course row 6,7 and 8 was added the very last.

The content of each row is not mixed, only the ID order.

Is it a very confused, because we develop mobile invoice programs for PDAs.

What I did wrong?

Thank you!

Does that happen in the Query Analyzer on the PDA?

Maybe it does not order the rows by the primary key column by default (?). I don't know if that would be a bug, although it sounds more convenient if it did order on any key columns.

|||I moved this thread to the SQL Mobile's team forusm|||

Neither SQL Server nor SQL Mobile guarrenty you about the physical order of the rows and you are not expected to concluded something from running multiple queries. It can always change. If you want the rows to be ordered on a column, you should ideally use ORDER BY. Your query result (with out ordering) always depends on the cursor position.

Thanks,

Laxmi Narsimha Rao ORUGANTI, MSFT, SQL Mobile, Microsoft Corporation

Is is necessary for a table which will be part of the Replication process to have a and Primary

Hi there,

We're going to use replication on our database. There are tables without any primary key.

Is a primary key necessary for replication?

I have also antoher question: We want to replicate the whole OLTP database (size 30 GB).

Is snapshot replication a suitable mechanisme for this? I thougt snapshot replication overwrites all of the data, not only changed data. Or should we use another replication method?

Thanks in advance,

Patrick de Jong

A primary key is necessary to replicate an article so that a unique record can always be found. Snapshotting a 30gb everytime might not be such a great idea. Transactional is probably a better way to go, depending on your situation.
Tim|||

Yes you need to have a primary key on each table for replication.

Depending on how often your data changes and how frequently you need to have the subscriber updated is the best way to decide if snapshot replication is the best method.

Typically snapshot is not the best option unless you have a very high data change rate and you only need the subscriber updated once or twice per day (or less frequently).

|||

Thanks for the answer's. The really helped me.

1.) My customer has te deside on which fields the pk must come.

2.) I think we will use transactional replication.

Greetz,

Patrick de Jong

|||

Hi Friends,

1.Yes a table involved in Transactional replication should have a primary key defined.Also if u hav opted for transactional publication with updating subscriber,a unique identifier is required for a table.

2.Since it is a OLTP Database it keeps changing frequently,my suggestion would be to go for Transactional Replication.

Always prefer Snapshot replication for datas which do not change frequently (OLAP environment)

Rgds

Deepak

|||

Thanks Deepak,

Today we've made a list of tables without a PK. It seems to be no problem to add the missing PK's because the tabels had an identity which was used as some sort of PK. Tomorrow we will test transactional replication.

Greetz,

Patrick de Jong

Friday, February 24, 2012

Is Index useful?

Hi
In a table A (currently holding approx. 4700 rows but will
expand during use) the primary key is a combination of
three columns col1, col2, col3.
The primary key is indexed with a clustered index
(FillFactor 90).
On the columns col1, col2 an nonclustred index have been
added (FillFactor 90) too, this because I guess these two
columns together form a foreign key to another table B
(currently holding approx 1000 rows - number will raise).
The two indexes are both sorted ascending for all values.
My assumption is that the nonclustered index are of no use
and only adds overhead to inserts etc., since both col1
and col2 allready are indexed (in same sequence and sort
order) in the clustered index, so a query on col1 and/or
col2, and a join between table A and B can already use the
clustered index values for the col1, col2 to speed up the
query and the join using a merge join.
Infact the DBCC SHOWSTATISTIC returns the exact same
result (density etc.) for both the clusterd and
nonclustered index (propably because the nonclustered
index after having scanned its only structure will point
to the clustered index anyway and use this afterwards - to
my recollection).
But does the extra col3 of the clustered index make it
useless for queries/order by/joins on only col1, col2?
or
Can I - with a good nights sleep in mind - just delete the
nonclustered index as it is superflous?
Kind regards
Jakob PerssonJacob
On which column(s) do you have clustered index?
What is mostly WHERE caluse in your queries?
If all three columns are participated in your query you probably want to
consider using COVERING index.
A clustered index is more useful where you try to retrive a set of data ( a
lot of rows) on other hand a non clustered index will be more useful where
you retrieve a single row.
Again it is depends upon you requriments, you will have to monitor your
query to find out an appropritate indexes
SET STATISTICS IO may be useful ,also look at excution plan of the query.
"Jakob Persson" <jakobpersson@.yahoo.dk> wrote in message
news:084601c3b8bc$173b71c0$a501280a@.phx.gbl...
> Hi
> In a table A (currently holding approx. 4700 rows but will
> expand during use) the primary key is a combination of
> three columns col1, col2, col3.
> The primary key is indexed with a clustered index
> (FillFactor 90).
> On the columns col1, col2 an nonclustred index have been
> added (FillFactor 90) too, this because I guess these two
> columns together form a foreign key to another table B
> (currently holding approx 1000 rows - number will raise).
> The two indexes are both sorted ascending for all values.
> My assumption is that the nonclustered index are of no use
> and only adds overhead to inserts etc., since both col1
> and col2 allready are indexed (in same sequence and sort
> order) in the clustered index, so a query on col1 and/or
> col2, and a join between table A and B can already use the
> clustered index values for the col1, col2 to speed up the
> query and the join using a merge join.
> Infact the DBCC SHOWSTATISTIC returns the exact same
> result (density etc.) for both the clusterd and
> nonclustered index (propably because the nonclustered
> index after having scanned its only structure will point
> to the clustered index anyway and use this afterwards - to
> my recollection).
> But does the extra col3 of the clustered index make it
> useless for queries/order by/joins on only col1, col2?
> or
> Can I - with a good nights sleep in mind - just delete the
> nonclustered index as it is superflous?
> Kind regards
> Jakob Persson
>|||Jakob,
>But does the extra col3 of the clustered index make it
>useless for queries/order by/joins on only col1, col2?
No. The index with col1, col2, col3 is just as useful as the one with col1, col2. So your thinking
is spot on. One thing is of course if col1 and col2 are very narrow and col3 is very wide, but that
is obvious.
Another, more important issue, is that the index on col1, col2 is an NC index which has other
characteristics than a clustered index. The optimizer might use this index to cover queries (or
partially cover), which can have significant performance gains compared to a clustered index.
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"Jakob Persson" <jakobpersson@.yahoo.dk> wrote in message
news:084601c3b8bc$173b71c0$a501280a@.phx.gbl...
> Hi
> In a table A (currently holding approx. 4700 rows but will
> expand during use) the primary key is a combination of
> three columns col1, col2, col3.
> The primary key is indexed with a clustered index
> (FillFactor 90).
> On the columns col1, col2 an nonclustred index have been
> added (FillFactor 90) too, this because I guess these two
> columns together form a foreign key to another table B
> (currently holding approx 1000 rows - number will raise).
> The two indexes are both sorted ascending for all values.
> My assumption is that the nonclustered index are of no use
> and only adds overhead to inserts etc., since both col1
> and col2 allready are indexed (in same sequence and sort
> order) in the clustered index, so a query on col1 and/or
> col2, and a join between table A and B can already use the
> clustered index values for the col1, col2 to speed up the
> query and the join using a merge join.
> Infact the DBCC SHOWSTATISTIC returns the exact same
> result (density etc.) for both the clusterd and
> nonclustered index (propably because the nonclustered
> index after having scanned its only structure will point
> to the clustered index anyway and use this afterwards - to
> my recollection).
> But does the extra col3 of the clustered index make it
> useless for queries/order by/joins on only col1, col2?
> or
> Can I - with a good nights sleep in mind - just delete the
> nonclustered index as it is superflous?
> Kind regards
> Jakob Persson
>

Is DEFAULT a constraint?

Hi,

I see the following in Books Online: CONSTRAINT--Is an optional keyword
indicating the beginning of a PRIMARY KEY, NOT NULL, UNIQUE, FOREIGN
KEY, or CHECK constraint definition...

But I have a table column defined as follows:

[MONTH] [decimal] (2, 0) NOT NULL CONSTRAINT
[DF__TBLNAME__MONTH__216361A7] DEFAULT (0)

My question: Is "DEFAULT" a constraint, or is it called something else?

Thanks,
EricEric Bragas (ericbragas@.yahoo.com) writes:

Quote:

Originally Posted by

I see the following in Books Online: CONSTRAINT--Is an optional keyword
indicating the beginning of a PRIMARY KEY, NOT NULL, UNIQUE, FOREIGN
KEY, or CHECK constraint definition...
>
But I have a table column defined as follows:
>
[MONTH] [decimal] (2, 0) NOT NULL CONSTRAINT
[DF__TBLNAME__MONTH__216361A7] DEFAULT (0)
>
My question: Is "DEFAULT" a constraint, or is it called something else?


There are actually two sorts of defaults: bound defaults and default
constraints. Bound defaults are deprecated, but are useful when you
bind them to types.

What you have above, is indeed a default constraints.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Thank you for the clarification.