确定
取消
×
仅自己可见
【sql】sqlserver清理ldf文件
576

USE prj--数据库名称GOALTER DATABASE prj SET RECOVERY SIMPLE WITH NO_WAITGOALTER DATABASE prj SET RECOVERY SIMPLE --简单模式GOUSE prjGODBCC SHRINKFILE (N'prj_log' , 11, TRUNCATEONLY)--这个日志文件可能不是我们在盘符里看到的,需要运行下边的语句进行查询GO --'这里的DNName_Log 如果不知道在sys.database_files里是什么名字的话,可以用以下注释的语句进行查询--USE sqqhxxdata--GO--SELECT file_id, name FROM sys.database_files;--GO USE prjGOALTER DATABASE prj SET RECOVERY FULL WITH NO_WAITGOALTER DATABASE prj SET RECOVERY FULL --还原为完全模式GO

(1) (0)
纯js回到顶部(流畅动画版)
(function smoothscroll(){    var currentScroll = document.documentElement.scrollTop || document.body.scrollTop;    if (currentScroll > 0) {         window.requestAnimationFrame(smoothscroll);         window.scrollTo (0,currentScroll - (currentScroll/5));    }})();

(0) (0)
test
OperatorRight Operand TypeDescriptionExampleExample Result
->intGet JSON array element (indexed from zero, negative integers count from the end)'[{"a":"foo"},{"b":"bar"},{"c":"baz"}]'::json->2{"c":"baz"}
->textGet JSON object field by key'{"a": {"b":"foo"}}'::json->'a'{"b":"foo"}
->>intGet JSON array element as text'[1,2,3]'::json->>23
->>textGet JSON object field as text'{"a":1,"b":2}'::json->>'b'2
#>text[]Get JSON object at specified path'{"a": {"b":{"c": "foo"}}}'::json#>'{a,b}'{"c": "foo"}
#>>text[]Get JSON object at specified path as text'{"a":[1,2,3],"b":[4,5,6]}'::json#>>'{a,2}'3

Note: There are parallel variants of these operators for both the json and jsonb types. The field/element/path extraction operators return the same type as their left-hand input (either json or jsonb), except for those specified as returning text, which coerce the value to text. The field/element/path extraction operators return NULL, rather than failing, if the JSON input does not have the right structure to match the request; for example if no such element exists. The field/element/path extraction operators that accept integer JSON array subscripts all support negative subscripting from the end of arrays.

The standard comparison operators shown in Table 9-1 are available for jsonb, but not for json. They follow the ordering rules for B-tree operations outlined at Section 8.14.4.

Some further operators also exist only for jsonb, as shown in Table 9-43. Many of these operators can be indexed by jsonb operator classes. For a full description of jsonb containment and existence semantics, see Section 8.14.3Section 8.14.4describes how these operators can be used to effectively index jsonb data.

Table 9-43. Additional jsonb Operators

OperatorRight Operand TypeDescriptionExample
@>jsonbDoes the left JSON value contain the right JSON path/value entries at the top level?'{"a":1, "b":2}'::jsonb @> '{"b":2}'::jsonb
<@jsonbAre the left JSON path/value entries contained at the top level within the right JSON value?'{"b":2}'::jsonb <@ '{"a":1, "b":2}'::jsonb
?textDoes the string exist as a top-level key within the JSON value?'{"a":1, "b":2}'::jsonb ? 'b'
?|text[]Do any of these array strings exist as top-level keys?'{"a":1, "b":2, "c":3}'::jsonb ?| array['b', 'c']
?&text[]Do all of these array strings exist as top-level keys?'["a", "b"]'::jsonb ?& array['a', 'b']
||jsonbConcatenate two jsonb values into a new jsonb value'["a", "b"]'::jsonb || '["c", "d"]'::jsonb
-textDelete key/value pair or string element from left operand. Key/value pairs are matched based on their key value.'{"a": "b"}'::jsonb - 'a'
-integerDelete the array element with specified index (Negative integers count from the end). Throws an error if top level container is not an array.'["a", "b"]'::jsonb - 1
#-text[]Delete the field or element with specified path (for JSON arrays, negative integers count from the end)'["a", {"b":1}]'::jsonb #- '{1,b}'

Note: The || operator concatenates the elements at the top level of each of its operands. It does not operate recursively. For example, if both operands are objects with a common key field name, the value of the field in the result will just be the value from the right hand operand.

Table 9-44 shows the functions that are available for creating json and jsonb values. (There are no equivalent functions for jsonb, of the row_to_json and array_to_json functions. However, the to_jsonb function supplies much the same functionality as these functions would.)

Table 9-44. JSON Creation Functions

FunctionDescriptionExampleExample Result

to_json(anyelement)

to_jsonb(anyelement)

Returns the value as json or jsonb. Arrays and composites are converted (recursively) to arrays and objects; otherwise, if there is a cast from the type to json, the cast function will be used to perform the conversion; otherwise, a scalar value is produced. For any scalar type other than a number, a Boolean, or a null value, the text representation will be used, in such a fashion that it is a valid json or jsonb value.to_json('Fred said "Hi."'::text)"Fred said \"Hi.\""
array_to_json(anyarray [, pretty_bool])Returns the array as a JSON array. A PostgreSQL multidimensional array becomes a JSON array of arrays. Line feeds will be added between dimension-1 elements if pretty_bool is true.array_to_json('{{1,5},{99,100}}'::int[])[[1,5],[99,100]]
row_to_json(record [, pretty_bool])Returns the row as a JSON object. Line feeds will be added between level-1 elements if pretty_bool is true.row_to_json(row(1,'foo')){"f1":1,"f2":"foo"}

json_build_array(VARIADIC "any")

jsonb_build_array(VARIADIC "any")

Builds a possibly-heterogeneously-typed JSON array out of a variadic argument list.json_build_array(1,2,'3',4,5)[1, 2, "3", 4, 5]

json_build_object(VARIADIC "any")

jsonb_build_object(VARIADIC "any")

Builds a JSON object out of a variadic argument list. By convention, the argument list consists of alternating keys and values.json_build_object('foo',1,'bar',2){"foo": 1, "bar": 2}

json_object(text[])

jsonb_object(text[])

Builds a JSON object out of a text array. The array must have either exactly one dimension with an even number of members, in which case they are taken as alternating key/value pairs, or two dimensions such that each inner array has exactly two elements, which are taken as a key/value pair.

json_object('{a, 1, b, "def", c, 3.5}')

json_object('{{a, 1},{b, "def"},{c, 3.5}}')

{"a": "1", "b": "def", "c": "3.5"}

json_object(keys text[], values text[])

jsonb_object(keys text[], values text[])

This form of json_object takes keys and values pairwise from two separate arrays. In all other respects it is identical to the one-argument form.json_object('{a, b}', '{1,2}'){"a": "1", "b": "2"}

Note: array_to_json and row_to_json have the same behavior as to_json except for offering a pretty-printing option. The behavior described for to_json likewise applies to each individual value converted by the other JSON creation functions.

Note: The hstore extension has a cast from hstore to json, so that hstore values converted via the JSON creation functions will be represented as JSON objects, not as primitive string values.

(0) (0)
111
29

以色列 UI 设计师 GAL SHIR 有一系列的 Gif 作品。

极简的可爱画风,巧妙的循环,拟人的身边事物,小编轻轻松松就看了一天。

Timing Is Everything

I Love You, Responsive

Fish

Domino

Matryoshka Doll

(1) (0)
test
1
此人很懒,什么也没写...
(0) (0)
test
1
此人很懒,什么也没写...
(0) (0)
【sql】COALESCE
576
此人很懒,什么也没写...
(0) (0)
呜呜呜

荒邪堕落者恶魔形态:107.9

心渊魔角:324

繁盛北极星:25

龙锻之耀:197.9

骄阳勇士鬃毛:29.1

女神利爪:50.77

净魂之刃:112

龙焰信徒:580

猛兽之心利爪:31.4

闪现之爪:55.66

(1) (0)
【SQL】sqlserver怎么用sql查看具体那个表被锁住了
576

查看被锁表:select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableNamefrom sys.dm_tran_locks where resource_type='OBJECT'--spid 锁表进程--tableName 被锁表名解锁:declare @spid intSet @spid = 57 --锁表进程declare @sql varchar(1000)set @sql='kill '+cast(@spid as varchar)exec(@sql)--查询出死锁的SPIDselect blockedfrom (select * from sysprocesses where blocked>0 ) awhere not exists(select * from (select * from sysprocesses where blocked>0 ) bwhere a.blocked=spid)--输出引起死锁的操作DBCC INPUTBUFFER (@spid)--查询当前进程数select count(-1) from sysprocesseswhere dbid in (select dbid from sysdatabases where name like '%telcount%');  

(0) (0)
【git】commit之后,想撤销commit
576

写完代码后,我们一般这样git add . //添加所有文件git commit -m "本功能全部完成"执行完commit后,想撤回commit,怎么办?这样凉拌:git reset --soft HEAD^这样就成功的撤销了你的commit注意,仅仅是撤回commit操作,您写的代码仍然保留。说一下个人理解:HEAD^的意思是上一个版本,也可以写成HEAD~1如果你进行了2次commit,想都撤回,可以使用HEAD~2至于这几个参数:--mixed 意思是:不删除工作空间改动代码,撤销commit,并且撤销git add . 操作这个为默认参数,git reset --mixed HEAD^ 和 git reset HEAD^ 效果是一样的。--soft  不删除工作空间改动代码,撤销commit,不撤销git add . --hard删除工作空间改动代码,撤销commit,撤销git add . 注意完成这个操作后,就恢复到了上一次的commit状态。顺便说一下,如果commit注释写错了,只是想改一下注释,只需要:git commit --amend此时会进入默认vim编辑器,修改注释完毕后保存就好了。--------------------- 原文链接:https://blog.csdn.net/w958796636/article/details/53611133

(0) (0)
【sql】select into 没法插入一个已存在的表
576

select into 没法插入一个已存在的表

(3) (0)
【sql】分组取每组第一行值
576
--方法1:select a.* from tb a where val = (select max(val) from tb where name = a.name) order by a.name --方法2: select a.* from tb a where not exists(select 1 from tb where name = a.name and val > a.val) --方法3: select a.* from tb a,(select name,max(val) val from tb group by name) b where a.name = b.name and a.val = b.val order by a.name --方法4: select a.* from tb a inner join (select name , max(val) val from tb group by name) b on a.name = b.name and a.val = b.val order by a.name --方法5 select a.* from tb a where 1 > (select count(*) from tb where name = a.name and val > a.val ) order by a.name

结果显示1,3,4效率相同,2,5效率差些  

--需要把限制查询条件写在子查询中 否则可能查询条数变少,因为取top的时候没有限制可能取到的rpstatus不是29 --错误 select a.col_r_no,a.col_rp_status, a.* from sys_cos_report_tracklog a where a.col_rp_status='29' and a.id = (select top(1) b.id from sys_cos_report_tracklog b where b.col_r_no=a.col_r_no) --正确select a.col_r_no,a.col_rp_status, a.* from sys_cos_report_tracklog a where a.id = (select top(1) b.id from sys_cos_report_tracklog b where b.col_r_no=a.col_r_no and b.col_rp_status='29')

(4) (0)
React Hooks useState is not consistent with Object
5
0

I have this piece of code.

import React, { useState, useEffect } from 'react';
export default function Example() {
const [object, setObject] = useState({
count
: 0
});

const onClick = () => {
setObject
(old => {
old
.count = old.count + 1;
return old;
});
};

return (
<div>
<p>You clicked {object.count} times</p>
<button onClick={e => console.log(object.count)}>Show in log</button>
<button onClick={onClick}>Click me</button>
</div>
);
}

If you click the "Click me", it will increase the count property of the object. But for some reasons, if you click it, the object still get update but the component won't re-render. You can check the object's value it with "Show in log" button.

According to reactjs.org, whenever you set the state of a component, it will re-render. But if you write it like this, it won't.

But if i change the onClick function to

const onClick = () => {
setObject
(oldObject => {
const newObject = { ...oldObject };
newObject
.count = oldObject.count + 1;
return newObject;
});
};

Then it will re-render the component.

Can anyone please explain what is causing the strange behavior?

asked Jul 15 at 7:30
Tạ Sinh Phúc
1333 bronze badges
1

What you are doing in your first code snippet mutates the original state -- which is almost always a big no go in React world. React usually only rerenders if some state or prop has changed, and since you mutate original state it doesn't look like state has changed.

In your second example you create a copy of the original state (const newObject = {...oldObject}). Mutating the copy and returning it is fine -- you are not mutating original state.

answered Jul 15 at 7:35
Phillip
2,3521010 silver badges1616 bronze badges
0

Try setting the object like this:

const onClick = () => {
setObject
({
count
: object.count + 1
});
};
answered Jul 15 at 7:35
SiddAjmera
19.1k33 gold badges1414 silver badges4444 bronze badges
0

You need to return object. you are not returning right object. Trying doing like this :

const onClick = () => {
// setObject({...object, count:object.count+1}); //another way

setObject
(old => {
console
.log(old)
let updatedCount = old.count + 1
return {...old,count: updatedCount};
});
};

Live example : https://stackblitz.com/edit/react-sfjzgz

answered Jul 15 at 7:41
Shubham Verma
29788 bronze badges
0

setObject is a dispatch function. React designed it the way, that the only thing you need to provide it is a new value, this value is to be considered a changed state.

What you do is, you provide a function type into the dispatch function, as well as then mutate the object given to you as a parameter of the function.

What you do

const onClick = () => {
setObject
(old => { // <-- a function is provided here
old
.count = old.count + 1;
return old;
});
};

What you need to do

const onClick = () => {
setObject
({...object, count: object.count + 1});
// this way no mutation of the original state value is happening,
//and you are guaranteed to have a re-render.
};

And please stop calling variable object and setObject I know this is just an example, but posting this code snippet can very likely get you confused on type/name situation.

answered Jul 15 at 8:05
George.S
15377 bronze badges
  • Thank you for your answer. This example is just a simple one so you can setObject directly like that. But because i was working with a complex object that needs to do multiple action before it can set the state. That's when i found out about this behavior. – Tạ Sinh Phúc Jul 15 at 8:57
  • Well you can change your object in whatever way you like, but don't change the original state object - always make a copy of it, and when you are happy about it, put it into setObject. Also don't try to keep everything in one state object, just a reminder. You can create as many state objects as you like. – George.S Jul 15 at 9:00
(0) (0)
快速构建js数组
1
此人很懒,什么也没写...
(1) (0)
Tomcat Server处理一个HTTP请求的过程
576

1、用户点击网页内容,请求被发送到本机端口8080,被在那里监听的Coyote HTTP/1.1Connector获得。 2、Connector把该请求交给它所在的Service的Engine来处理,并等待Engine的回应。 3、Engine获得请求localhost/test/index.jsp,匹配所有的虚拟主机Host。 4、Engine匹配到名为localhost的Host(即使匹配不到也把请求交给该Host处理,因为该Host被定义为该Engine的默认主机),名为localhost的Host获得请求/test/index.jsp,匹配它所拥有的所有的Context。Host匹配到路径为/test的Context(如果匹配不到就把该请求交给路径名为“ ”的Context去处理)。 5、path=“/test”的Context获得请求/index.jsp,在它的mapping table中寻找出对应的Servlet。Context匹配到URL PATTERN为*.jsp的Servlet,对应于JspServlet类。 6、构造HttpServletRequest对象和HttpServletResponse对象,作为参数调用JspServlet的doGet()或doPost().执行业务逻辑、数据存储等程序。 7、Context把执行完之后的HttpServletResponse对象返回给Host。 8、Host把HttpServletResponse对象返回给Engine。 9、Engine把HttpServletResponse对象返回Connector。 10、Connector把HttpServletResponse对象返回给客户Browser

(0) (0)
1 / 14
Bio:{{user.bio== undefined?'(→_→)Nothing':user.bio}}
发帖
个人中心
消息
{{noticeNum}}
登出