SQL如何更改约束
以下是我的约束条件之一
CONSTRAINT ACTIVEPROG_FKEY1 FOREIGN KEY(ActiveProgCode) REFERENCES PROGRAM(ActiveProgCode),
Run Code Online (Sandbox Code Playgroud)
我想加入
ON DELETE CASCADE
Run Code Online (Sandbox Code Playgroud)
到上面的约束.
如何更改现有约束ACTIVEPROG_FKEY1并添加
ON DELETE CASCADE
Run Code Online (Sandbox Code Playgroud)
约束ACTIVEPROG_FKEY1
考虑ACTIVEPROG_FKEY1在表ACTIVEPROG
为了获得当前日期,我使用此..
select extract(year from sysdate) from dual;
Run Code Online (Sandbox Code Playgroud)
为了得到我的数据库保持的日期我使用这个..
select extract(year from startdate) from staff;
Run Code Online (Sandbox Code Playgroud)
但现在我正在尝试通过使用更新现场工作人员的字段调用serviceYears
current year - year of start date
获得员工承诺工作的年数.我该如何实现它..
我正在使用oracle sql
谢谢!
我试着用
SQL> select dual.sysdate-staff.startdatefrom dual,staff;
select dual.sysdate-staff.startdatefrom from dual,staff
*
ERROR at line 1:
ORA-01747: invalid user.table.column, table.column, or column specification
Run Code Online (Sandbox Code Playgroud)
我也试过了
select SYSDATE-to_date('01-jan-2007','dd-mon-yyyy') from dual;
But it return me
SYSDATE-TO_DATE('01-JAN-2007','DD-MON-YYYY')
--------------------------------------------
2136.93719
Run Code Online (Sandbox Code Playgroud)
我怎么才能获得这一年?
string str1 = "hello";
const char* string1 = str1;
Run Code Online (Sandbox Code Playgroud)
我收到一个错误..
在初始化时无法将'std :: string {aka std :: basic_string}'转换为'const char*'
我如何将字符串转换为const char*
谢谢你的帮助
如何使单选按钮更改表单操作地址
我有一张表格,内容如下
和一个单选按钮
<b>Would you like to to make payment ? <input type="radio" name="choice" value="yes">Yes <input type="radio" name="choice" value="no" checked>No</b>'
Run Code Online (Sandbox Code Playgroud)
如果用户选择no(默认选中),则表单action仍为register_page4.php
但如果用户选择yes并按下提交按钮:
<input id="btnSubmit" type="submit" value="Next" />
Run Code Online (Sandbox Code Playgroud)
我希望表单操作是payment.php而不是register_page4.php,我该如何实现它.
我进行了更改,这就是我输入的内容
<html>
<head>
</head>
<body>
<form name="form1" method="post" action="register_page4.php">
Would you like to make an appointment for collection ?
<input type="radio" name="collection" value="yes">Yes
<input type="radio" name="collection" value="no" checked>No
<input id="btnSubmit" type="submit" value="Next" />
</form>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
jQuery(document).ready(function($) { …Run Code Online (Sandbox Code Playgroud) 我试图添加这个SQL检查
ALTER TABLE School
add Role check_role
CHECK (check_role IN ('Teaching Assistant', 'Lecturer', 'Professor'));
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
ERROR at line 3:
ORA-02438: Column check constraint cannot reference other columns
SQL> desc School;
Name Null? Type
----------------------------------------- -------- ----------------------------
STAFFNUM NOT NULL VARCHAR2(12)
NAME NOT NULL VARCHAR2(50)
ADDRESS NOT NULL VARCHAR2(300)
DOB DATE
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用检查约束check_role添加列调用Role
我正在使用Oracle SQL.
谢谢大家的帮助!
下面是我的代码
#include <stdio.h>
#include <string.h>
#include <iostream>
int main()
{
std::string data;
data = "hello world";
char string[] = new char [data.length()+1];;
strcpy(string, data.c_str());
}
Run Code Online (Sandbox Code Playgroud)
我收到了一个错误..
file.cpp: In function ‘int main()’:
file.cpp:14:46: error: initializer fails to determine size of ‘string’
Run Code Online (Sandbox Code Playgroud)
我应该怎么做,因为我想将字符串数据的内容复制到char string []
谢谢你的帮助.
我需要创建一个可以包含我的父类和子类数据的向量.
这就是我做的..
车辆是父类
汽车是儿童班
关于Car.cpp,它得到了以下内容
struct Point
{
int x,y
};
class Car : public Vehicle
{
private:
Point wheelPoint[4];
double area;
public:
void setPoint();
};
void Car::setPoint()
{
int xData,yData;
cout << "Please enter X:";
cin >> xData;
cout << "Please enter Y:";
cin >> yData;
wheelPoint[i].x = xData;
wheelPoint[i].y = yData;
}
Run Code Online (Sandbox Code Playgroud)
然后在我的main.cpp
在我的main.cpp
vector<VehicleTwoD> list;
VehicleTwoD *vehicle;
Car *car = new Car;
string vehicleName;
cout << "Please input name of vehicle";
cin >> vehicleName;
vehicle = new …Run Code Online (Sandbox Code Playgroud) 一点信息
Parent Class: Vehicle
Child Class: Car & Motorcycle
Run Code Online (Sandbox Code Playgroud)
我有一个struct是
struct Point
{
int x,y;
};
Run Code Online (Sandbox Code Playgroud)
我得到了一个setPoint功能,在Car和Motorcycle其执行以下操作
因为Car有4个轮子,Motorcycle有2个轮子.
Car 将有这个功能
class Car : public Vehicle
{
private:
Point wheelPoint[4]; // if motorcycle then its wheelPoint[2]
public:
Point getPoint();
void setPoint();
}
void Car::setPoint()
{
int xData,yData;
for (int i=0;i<4;i++)
{
cout << "Please enter X :" ;
cin >> xData;
cout << "Please enter Y :" ;
cin …Run Code Online (Sandbox Code Playgroud) C++ ifstream获取从char到string的换行getline输出
我有一个文本文件..所以我读了它,我做了类似的事情
char data[50];
readFile.open(filename.c_str());
while(readFile.good())
{
readFile.getline(data,50,',');
cout << data << endl;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,不是通过变量名数据创建大小为50的字符,我可以将getline变为字符串而不是像
string myData;
readFile.getline(myData,',');
Run Code Online (Sandbox Code Playgroud)
我的文本文件是这样的
Line2D,[3,2] Line3D,[7,2,3]
我试过,编译器说..
没有匹配的getline函数(std :: string&,char)
所以仍然可以通过分隔符来分解,将值赋给字符串而不是char.
更新:
运用
while (std::getline(readFile, line))
{
std::cout << line << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
它逐行读取,但我想将字符串分成几个分隔符,原来如果使用char我将指定分隔符作为第3个元素是
readFile.getline(data,50,' , ');
如果我用分隔符逗号破解/爆炸,如何使用字符串,如上所述.逐行
我收到了这个字符串
0x3384BCFD
0x61CEB13B
Run Code Online (Sandbox Code Playgroud)
两者都是字符串类型..
最初我得到了这个
uint32_t iv[2] = {0xFFFFFFFF,0xFFFFFFAA};
Run Code Online (Sandbox Code Playgroud)
如何分配2串以上为iv[0]和iv[1]?
我想要的最终结果iv[2]为iv[2] = {0x3384BCFD,0x61CEB13B};
谢谢你的帮助!!
#include <stdio.h>
#include <string.h>
#include <openssl/sha.h>
#include <string.h>
#include <iostream>
#include <stdlib.h>
#include <sstream>
using namespace std;
int main()
{
std::stringstream ss;
std::string data;
data = "hello worl";
unsigned char digest[SHA_DIGEST_LENGTH];
char *string1 = strdup(data.c_str());
SHA1((unsigned char*)&string1, strlen(string1), (unsigned char*)&digest);
char mdString[SHA_DIGEST_LENGTH*2+1];
for(int i = 0; i < SHA_DIGEST_LENGTH; i++)
sprintf(&mdString[i*2], "%02x", (unsigned int)digest[i]);
ss.str("");
ss << mdString;
cout << ss.str() << std::endl;
// do stuff with string1
free(string1);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:
user1@ubuntu:~/yes/coding$ g++ -o sha sha.cpp -lcrypto
user1@ubuntu:~/yes/coding$ …Run Code Online (Sandbox Code Playgroud) #include <stdio.h>
#include <string.h>
#include <openssl/sha.h>
#include <string.h>
#include <iostream>
#include <stdlib.h>
#include <sstream>
using namespace std;
int main()
{
std::stringstream ss;
std::string data;
data = "hello worl";
unsigned char digest[SHA_DIGEST_LENGTH];
char *string1 = strdup(data.c_str());
// do stuff with string1
free(string1);
SHA1((unsigned char*)&string1, strlen(string1), (unsigned char*)&digest);
char mdString[SHA_DIGEST_LENGTH*2+1];
for(int i = 0; i < SHA_DIGEST_LENGTH; i++)
sprintf(&mdString[i*2], "%02x", (unsigned int)digest[i]);
ss.str("");
ss << mdString;
cout << ss.str() << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我的输出总是一样的..
./sha
da39a3ee5e6b4b0d3255bfef95601890afd80709
Run Code Online (Sandbox Code Playgroud)
即使我将数据内容更改为"hello panda"或"hello ki"也给我相同的输出.
更新:我带走了免费
user1@ubuntu:~/yes/coding$ …Run Code Online (Sandbox Code Playgroud)