我在STUDENTSINTEST表中有两列
1.TestID 2.StudentID
两者都是某些表的外键,现在我想知道如何将这两列设置为STUDENTSINTEST表的复合主表?非常感谢....
答案 0 :(得分:3)
如果您的表已经定义
alter table STUDENTSINTEST add constraint STUDENTSINTEST_PK primary key(TestID,StudentID);
否则您可以将以下语句添加到CREATE TABLE语句
constraint STUDENTSINTEST_PK primary key(TestID,StudentID)
答案 1 :(得分:0)
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.otts.*" %>
<%@ page import="com.otts.dao.TestProfile" %>
<%-- Variables declaration --%>
<link type="text/css" href="/TandQMgmt/css/menu.css" rel="stylesheet" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="menu.js"></script>
<link href="/TandQMgmt/css/style.css" rel="stylesheet" type="text/css" />
<script src="../js/jquery.js" ></script>
<script src="../js/jquery-ui.js" ></script>
<script src="../js/jquery-validate.js" ></script>
<body>
<div class="contanier">
<div class="content-beginner">
<div class="logo"></div>
<div class="heading-bar">
<div class="heading-text"></div>
<div class="clear"></div>
</div>
</ul></div>
</li>
</ul></div>
</li>
<li class="last"><a href="#"><span>Help & Support </span></a></li>
</ul>
</div>
<div class="clear"></div>
<script>
$(function() {
$( "input:submit").button();})
function validateregisterform(){
$("form#Formviewtest").validate();
}
</script>
<%
if(request.getAttribute("indicator")=="view"){ %>
<p align="center">
<table width="800" height="281" border="1" bgcolor="#FFFFFF">
<tr>
<td height="33" colspan="7" bgcolor="#663300"><h1 style="font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; font-size:16px; color:#FFF;">View Test Details</h1></td>
</tr>
<tr>
<td width="96" bgcolor="#e3d5a8"><h2 style="font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; font-size:13px; color:#C30; text-align:center;">TESTID</h2></td>
<td width="96" bgcolor="#e3d5a8"><h2 style="font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; font-size:13px; color:#C30; text-align:center;">TEST NAME</h2></td>
<td width="96" bgcolor="#e3d5a8"><h2 style="font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; font-size:13px; color:#C30; text-align:center;">TEACHER ID</h2></td>
<td width="96" bgcolor="#e3d5a8"><h2 style="font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; font-size:13px; color:#C30; text-align:center;">NO of PARTICIPANTS</h2></td>
<td width="96" bgcolor="#e3d5a8"><h2 style="font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; font-size:13px; color:#C30; text-align:center;">CURRENTLY ALLOCATED</h2></td>
<td width="96" bgcolor="#e3d5a8"><h2 style="font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; font-size:13px; color:#C30; text-align:center;">DURATION</h2></td>
<td width="96" bgcolor="#e3d5a8"><h2 style="font-family:'Trebuchet MS', Arial, Helvetica, sans-serif; font-size:13px; color:#C30; text-align:center;">CREATED BY</h2></td>
</tr>
<%ArrayList userList=null;
userList=(ArrayList) request.getAttribute("totalResultSet");
for(int i=0;i<userList.size();i++)
{
TestProfile testProfile = (TestProfile) userList.get(i);
%>
<tr>
<td><%out.print(testProfile.getTestId());%></td>
<td><%out.print(testProfile.getTestName());%></td>
<td><%out.print(testProfile.getTeacherId());%></td>
<td><%out.print(testProfile.getNumberOfParticipants());%></td>
<td><%out.print(testProfile.getCurrentlyAllocated());%></td>
<td><%out.print(testProfile.getDuration());%> </td>
<td><%out.print(testProfile.getCreatedBy()); %> </td>
</tr>
<% }%>
</p>
</table>
<%}
else { %>
<form name="Formviewtest" id="Formviewtest" onsubmit="return validateregisterform()" action="../TestandQuestionManagement" method="post">
<pre>
<input type="submit" name ="Submit" value="View Test"></input>
</pre>
</div>
</div>
</div>
</form>
</body>
</html>
<%}%>
答案 2 :(得分:0)
<script type="text/javascript">
function show_confirm()
{
var r=confirm("Do You wish to update test details?");
if (r==true)
{
alert("Test details updated!");
}
return false;
}
function validate(form){
var testName1 = form.testName.value;
var duration1 = form. duration.value;
var noofParticipants1 = form.noofParticipants.value;
var teacherId1 = form.teacherId.value;
if(testName1.length==0){
alert("Please enter a Test name");
return false;
}
if(testName1.length>10){
alert("Please enter a Test name lessthan or equal to 10");
return false;
}
if(duration1.length==0){
alert("Please enter a test duration");
return false;
}
if(duration1/1!=duration1){
alert("Please enter a test duration in numbers");
return false;
}
if(duration1<15 )
{
alert("Please enter a test duration greater than 15");
return false;
}
if(duration1>300 )
{
alert("Please enter a test duration less than 300");
return false;
}
if(noofParticipants1.length==0){
alert("Please enter a number of participants");
return false;
}
if(noofParticipants1/1!=noofParticipants1){
alert("Please enter a number of participants in numbers");
return false;
}
if(teacherId1.length==0){
alert("Please enter a Teacher Id");
return false;
}
if(teacherId1/1!=teacherId1){
alert("Please enter a teacher Id in numbers");
return false;
}
return true;
}
</script>
<title>Update test</title>
答案 3 :(得分:0)
public static String DRIVERNAME="oracle.jdbc.driver.OracleDriver";
public static String SERVERNAME = "172.24.137.30";
public static String PORTNUMBER = "1521";
public static String SID = "ora10G";
public static String URL = "jdbc:oracle:thin:@" + SERVERNAME + ":" + PORTNUMBER + ":" + SID;
public static String USERNAME = "e554893 ";
public static String PASSWORD = "VAnjrmfvi";
Connection conn = null;
try {
// load the JDBC-ODBC Bridge driver
Class.forName(Constants.DRIVERNAME);
conn = DriverManager.getConnection(Constants.URL,
Constants.USERNAME, Constants.PASSWORD);
}
catch (Exception ex) {
System.out.println("Connection not created");
}
return conn;