如何在 PostgreSQL 数据库中创建具有一列枚举数据类型的表?
表名: Employee
列:
ID: Integer
Name: ENUM
Run Code Online (Sandbox Code Playgroud)
以下是查询,但不确定它是否正确。
CREATE TYPE Name AS ENUM();
CREATE TABLE IF NOT EXISTS Employee(
ID integer NOT NULL,
Name DEFAULT NULL,
CONSTRAINT "Employee_pkey" PRIMARY KEY (id)
);
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?
当我使用 nums={3,2,4} target = 6 调试此代码时,对于 key = 3 ,我得到的索引值为 1 而不是 0 ?有人可以告诉我为什么吗?
class Main {
public int[] twoSum(int[] nums, int target) {
HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
for(int i=0;i<nums.length;i++) {
map.put(nums[i],nums[i]);
}
Set<Integer> set = map.keySet();
ArrayList<Integer> list = new ArrayList<Integer>(set);
for(int i=0;i<nums.length-1;i++) {
if(map.containsKey(target-nums[i])) {
int key = map.get(target-nums[i]);
int index = list.indexOf(key);
if(index != i) {
nums = new int[2];
nums[0] = i;
nums[1] = index;
}
}
}
return nums;
}
}
Run Code Online (Sandbox Code Playgroud) 以下是我的JSON:
{
"key1" : "10.5",
"key2" : "20.5",
"key3" : "10.5",
"key4" : "20.5",
"key5" : "10.5"
}
Run Code Online (Sandbox Code Playgroud)
我想在调用post service时将这个Json发送到控制器类,我想根据类中的键迭代json.我们如何在课堂上收到json以及我们如何迭代.
我做了以下:
@PostMapping("/api/v1/save")
public String save_commodities_user_predict_data(@RequestBody String jsonData) {
System.out.println("jsonData:"+jsonData);
}
Run Code Online (Sandbox Code Playgroud)
在控制台中,我得到低于输出:
jsonData:{
"key1" : "10.5",
"key2" : "20.5",
"key3" : "10.5",
"key4" : "20.5",
"key5" : "10.5"
}
Run Code Online (Sandbox Code Playgroud)
现在,我如何迭代jsonData并根据我的java类中的键获取值?
请澄清.