473,396 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

extracting the constraints

how do i get the constraints associated with a table. is there any
system table which stores the constraint details. Atleast how do I know
if a column is nullable or not

Jul 25 '06 #1
4 2642
A column is nullable if its Required property is False:
Currentdb.TableDefs("MyTable").Fields("MyField").R equired
To see if it can accept a zero-length string:
Currentdb.TableDefs("MyTable").Fields("MyField").A llowZeroLength

Other contraints are stored in the Indexes of the table. For example the
Primary Key has its Primary property True:
Currentdb.TableDefs("MyTable").Indexes(0).Primary

For an example of looping through the Fields of the TableDef, listing names
and examining a property (Description in this case), see:
http://allenbrowne.com/func-06.html

For a utility that examines an Access database and identifies tables that
lack a primary key, foreign keys are that nullable, and so on, see
Database Issue Checker Utility
at:
http://allenbrowne.com/AppIssueChecker.html
The code might be informative if you are seeking to programmatically examine
the structure of a database.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
<sr*******@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
how do i get the constraints associated with a table. is there any
system table which stores the constraint details. Atleast how do I know
if a column is nullable or not

Jul 25 '06 #2

sr*******@gmail.com wrote:
how do i get the constraints associated with a table. is there any
system table which stores the constraint details. Atleast how do I know
if a column is nullable or not
You could run these and see if one gives you the info you need:

Option Compare Database
Option Explicit

Sub temp1()
Dim f As ADODB.Field
Dim r As ADODB.Recordset
Set r =
CurrentProject.Connection.OpenSchema(adSchemaRefer entialConstraints)
With r
Debug.Print .Fields.Count
While Not .EOF
Debug.Print "*****"
For Each f In .Fields
If Not IsNull(f.Value) Then
Debug.Print f.Name & ": " & f.Value
End If
Next f
.MoveNext
Wend
End With
End Sub

Sub temp2()
Dim f As ADODB.Field
Dim r As ADODB.Recordset
Set r =
CurrentProject.Connection.OpenSchema(adSchemaCheck Constraints)
With r
Debug.Print .Fields.Count
While Not .EOF
Debug.Print "*****"
For Each f In .Fields
If Not IsNull(f.Value) Then
Debug.Print f.Name & ": " & f.Value
End If
Next f
.MoveNext
Wend
End With
End Sub

Sub temp3()
Dim f As ADODB.Field
Dim r As ADODB.Recordset
Set r =
CurrentProject.Connection.OpenSchema(adSchemaConst raintColumnUsage)
With r
Debug.Print .Fields.Count
While Not .EOF
Debug.Print "*****"
For Each f In .Fields
If Not IsNull(f.Value) Then
Debug.Print f.Name & ": " & f.Value
End If
Next f
.MoveNext
Wend
End With
End Sub

Jul 25 '06 #3
Thanks a lot for the info. I guess the solutions given are through ADO.
Iam connecting through java jdbcodbc bridge. hence it will be helpful
if i can access any table and query NOT NULL constants etc.

Lyle Fairfield wrote:
sr*******@gmail.com wrote:
how do i get the constraints associated with a table. is there any
system table which stores the constraint details. Atleast how do I know
if a column is nullable or not

You could run these and see if one gives you the info you need:

Option Compare Database
Option Explicit

Sub temp1()
Dim f As ADODB.Field
Dim r As ADODB.Recordset
Set r =
CurrentProject.Connection.OpenSchema(adSchemaRefer entialConstraints)
With r
Debug.Print .Fields.Count
While Not .EOF
Debug.Print "*****"
For Each f In .Fields
If Not IsNull(f.Value) Then
Debug.Print f.Name & ": " & f.Value
End If
Next f
.MoveNext
Wend
End With
End Sub

Sub temp2()
Dim f As ADODB.Field
Dim r As ADODB.Recordset
Set r =
CurrentProject.Connection.OpenSchema(adSchemaCheck Constraints)
With r
Debug.Print .Fields.Count
While Not .EOF
Debug.Print "*****"
For Each f In .Fields
If Not IsNull(f.Value) Then
Debug.Print f.Name & ": " & f.Value
End If
Next f
.MoveNext
Wend
End With
End Sub

Sub temp3()
Dim f As ADODB.Field
Dim r As ADODB.Recordset
Set r =
CurrentProject.Connection.OpenSchema(adSchemaConst raintColumnUsage)
With r
Debug.Print .Fields.Count
While Not .EOF
Debug.Print "*****"
For Each f In .Fields
If Not IsNull(f.Value) Then
Debug.Print f.Name & ": " & f.Value
End If
Next f
.MoveNext
Wend
End With
End Sub
Jul 26 '06 #4
sr*******@gmail.com wrote:
Thanks a lot for the info. I guess the solutions given are through ADO.
Iam connecting through java jdbcodbc bridge. hence it will be helpful
if i can access any table and query NOT NULL constants etc.
Perhaps someone else will find my answers helpful. I am glad they are
of no use to you.

Jul 26 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Nazgul | last post by:
Hi! I want to implement a small tool in Python for distributing "patches" and I need Your advice. This application should be able to package all files chosen by a user into a self-extracting.exe...
2
by: Paul | last post by:
Hi: I am not sure whether somebody can sort it out for me. I am doing data transfer from one oracle database to another. Both of them has the same structure (like same tables etc).the only...
4
by: Dmitri | last post by:
I just looked at a coworker's stored procedure and this person is dropping 4 Foreign key constraints and then re-adding them after processing the required logic (updating rows in the 4 tables in...
2
by: DW | last post by:
Greetings: I have to do a one-off forceful change of some data in a database. I need to disable some FK constraints, make the data change, and then re-enable the constraints. My process will...
10
by: serge | last post by:
I am doing a little research on Google about this topic and I ran into this thread: ...
0
by: BobTheDatabaseBoy | last post by:
i've Googled some this morning, but to my surprise, i don't find any offering (for fee or open source), which would integrate with, say Jakarta Struts, to provide the UI edits from cataloged...
6
by: Werner | last post by:
Hi, I try to read (and extract) some "self extracting" zipefiles on a Windows system. The standard module zipefile seems not to be able to handle this. False Is there a wrapper or has...
4
by: apatel85 | last post by:
Hey Guys, Total Number of Records (Based on 5 fields): 1000 Total Unique Records (Based on 5 Fields): 990 Total number of fields: 5 I have question regarding extracting duplicates from the...
4
by: Bobby Edward | last post by:
I have an xsd dataset. I created a simple query called GetDataByUserId. I can preview the data fine! I created a very simple BLL function that calls it and returns a datatable. When I run...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.